49
votes

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?

6
cap production puma:restart since stage is required.Abhinay

6 Answers

60
votes

You can restart manually using the following command

bundle exec pumactl -P /home/deploy/.pids/puma.pid restart

Make sure you point to the correct pid path.

24
votes

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.

17
votes

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

2
votes

As far as I know, if you are using capistrano3-puma gem, you do not need to restart puma explicitly after deployment. There is a task add_default_hooks which does puma:smart_restart after deployment.

You can see the task list by cap -vT. I think cap puma:restart will do the work.

0
votes
cap production puma:stop
cap production puma:start

or

cap production puma:restart
0
votes

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