What is the right way to run multiple processes from my start command?
The information in this post is accurate as of the published date . Please make sure to check any linked documentation within the post for changes/updates.
I’ve read in the docs that I shouldn’t background a start process, as this will cause the supervisor process to start a second copy, but is it possible to run multiple processes from the start command? What is the right way to do this?
-
You cannot start multiple processes from the
start
command.If the process you start itself forks, that is fine provided that the parent process remains active and will terminate all children when it receives a
sigterm
message. Failure to do so will leave zombie processes lying around that may cause unexpected and unpredictable behavior. In that case, an off-the-shelf supervisor service is best as it is designed to do exactly that. This process is not recommended.In the vast majority of cases a background process of that sort is better handled using a
worker
container instead. See the documentation on how to configure one.0 -
Using a worker is the recommended way of starting more than one process. But if you are not able to use a worker and have no other way, it is technically possible to use
supervisord
to start multiple processes. Please only use this as a last resort.Example of running supervisord to run both
PHP
anddropboxd
dependencies: python: supervisor: '*' web: commands: start: "supervisord -n -c supervisor.conf"
supervisor.conf gets committed to the repository and looks like this:
[supervisord] logfile=/tmp/supervisord.log nodaemon=true minfds=1024 pidfile=/tmp/supervisord.pid [program:php] command=/usr/bin/start-php-app process_name=%(program_name)s autostart=true autorestart=true [program:dropbox] process_name=%(program_name)s command=/app/.dropbox-dist/dropboxd autostart=true autorestart=true
0
Please sign in to leave a comment.
Comments
2 comments