I want to launch ~10 php processes from a bash script. When one of them finishes, I’d like the bash script to launch another php process, and continue on indefinitely, always having ~10 php processes running.
What is the simplest way to do this?
The php file launched will be the same every time, but the php process will know to pull new values from the database so it’s processing new data each time. The file I need to launch and all it’s classes are already written in php.
Seems like a good fit for superivisord. The following configuration will make sure that 10 processes are always running, and deals with log rotation, which is also handy. All output, including stderr, will be written to /var/log/worker.log. With “autorestart=true”, supervisord will replace a child process as soon as it exits.
Once you have the supervisor config in place (usually /etc/supervisord/conf.d), you can use supervisorctl as a convenient way to start and stop the process group.