How to start Sinatra app using Puma
The following will look at config.ru
and start app using puma by default
cd myapp
rackup
Assuming we have a config.ru
similar to this
require './app'
# Sinatra (optional) config
enable :logging, :static
configure :production do
disable :logging
end
run Sinatra::Application
If you want to force use of puma use
rackup -s Puma
To allow a puma config file you must call puma directly ...
bundle exec puma -C "./config/puma.rb"
A sample config file is ./config/puma.rb
name = "myapp"
port 3003
environment "production"
RUN="/var/www/run/"
pidfile "#{RUN}/puma-#{name}.pid"
bind "unix://#{RUN}/puma-#{name}.sock"
state_path "#{RUN}/puma-#{name}.state"
tag name
workers 2
threads 1, 1
preload_app!
To run puma as daemon (after version 5.0) you need to use puma-daemon gem.
Add to Gemfile
and add daemonize
to puma.rb
require 'puma/daemon'
...
daemonize
I have NOT found any way to run puma from rackup
and using the puma config file ...
Kill server
Kill sever by sending SIGINT to server PID e.g.
sudo kill -SIGINT `cat ./run/puma-minew-server.pid`