Skip to main content

What is the right way to run multiple processes from my start command?

Comments

2 comments

  • Larry

    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
  • Matthias Van Woensel

    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 and dropboxd

    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.