210 Procfile support

Updated . Posted . Visible to the public.

If you need to run specific program(s) and be sure they will get restarted if they quit unexpectedly or after a reboot, then you can create a file named Procfile in your repository to be used by supervisord. This works best with capistrano-opscomplete Show archive.org snapshot .

If you want to use this feature, please contact ops@makandra.de so we can enable it for your deployment.

Procfile Syntax

Currenlty the Procfile features we support are rather limited, please be aware of this. The basic syntax of the Procfile is:

$program_name: $command

For example to automatically start sidekiq:

sidekiq: bundle exec sidekiq

Important: The defined commands should not daemonize, as supervisord does that for you and otherwise can't track the commands.

You can use environment variables in your command with %{ENV_VARIABLE}s where VARIABLE is the name of the environment variable like this:

app: %{ENV_APPDIR}s/current/run_app start

Deployment

After you've created the Procfile, you also need to setup the the tasks for the deployment. If you're already using capistrano-opscomplete Show archive.org snapshot , you can add these lines to your Capistrano config:

# Update and Restart supervisor config
after 'deploy:updating', 'opscomplete:supervisor:gen_config'
after 'deploy:published', 'opscomplete:supervisor:restart_procs'

There are more tasks and configuration options. Please refer to the README Show archive.org snapshot for those and more.

Available commands on the server

If you can't or don't want to integrate capistrano-opscomplete, you can use the shell commands available on the server. They're useful if you want to verify commands manually too.

  • supervisor_gen_config

This command generates the configuration for supervisord. You need to run it before the other commands and at least every time you change your Procfile. There is no harm running it at every deploy.

  • supervisor_restart_procs $program_name(optional)

This command rereads the supervisord configuration and (re)starts all configured programs. If specified only the $program_name will be (re)started.

  • supervisor_stop_procs $program_name(optional)

This command stops all your programs in case you want to them to be stopped while your deployment runs. If specified only the $program_name will be stopped.

  • supervisor_status $program_name(optional)

This command shows the status of all configured supervisord programs of the deployment. If specified only the $program_name will be shown.

  • supervisor_signal_procs $signal $program_name(optional)

This command sends the signal $signal (e.g. USR1 or TSTP) to all programs or if specified to $program_name.

Logs

The output of your programs (stdout and stderr) will get written into log files. You will find these logs here:

# stdout:
${appdir}/shared/log/${program_name}-1.log

# stderr:
${appdir}/shared/log/${program_name}-1.error.log
Last edit
Andreas Vöst
License
Source code in this card is licensed under the MIT License.
Posted by Kim Klotz to opscomplete (2019-04-04 13:31)