I'm using Rails, Puma, Capistrano3. I have installed the gem capistrano3-puma
as well. I started Puma with Puma Jungle https://github.com/puma/puma/tree/master/tools/jungle/upstart
How do I restart Puma during deployment?
I'm using Rails, Puma, Capistrano3. I have installed the gem capistrano3-puma
as well. I started Puma with Puma Jungle https://github.com/puma/puma/tree/master/tools/jungle/upstart
How do I restart Puma during deployment?
Production
If you are using capistrano on production you can:
cap production deploy:restart
Development
If you are on a development environment you can start to look for the pid
ps aux | grep puma
You will see something like this:
user 11654 0.0 13.4 870204 137016 ? Sl Jul07 0:39 puma 2.13.4 (tcp://0.0.0.0:3000) [NameOfYourApp]
The number next to the username, in this case 11654
is the process id (PID) of puma server. You can kill it manually and restart the server after. Run this command:
kill -s 15 11654
This command is saying kill the process with id 11654 using signal SIGTERM (code 15). SIGTERM kills the process 'kindly' closing all files, connections, cleaning buffers, etc.
Last you run this command:
puma -e development -p 3000 -d
Puma will be started again in development mode, listening on port 3000 and the execution will be demonized.
I ran into the issue where I need to restart puma after some environment changes and did not want to do a full deploy of the application.
I only wanted to restart puma and nginx. Here are the commands that worked for me:
$ bundle exec cap production deploy:restart
$ bundle exec cap production puma:restart
Hope that helps someone
Generic answer that will work on any platform and it is supported by Puma server itself, is to use tmp_restart
plugin.
Add to your config/puma.rb
plugin :tmp_restart
After that just touch the file (touch tmp/restart.txt
) when you want to restart the puma app.
Source: https://github.com/puma/puma/blob/master/lib/puma/plugin/tmp_restart.rb
cap production puma:restart
since stage is required. – Abhinay