Problem: I want to implement several php-worker processes who are listening on a MQ-server queue for asynchronous jobs. The problem now is that simply running this processes
It sounds like you already have a MQ up and running on a *nix system and just want a way to manage workers.
A very simple way to do so is to use GNU screen. To start 10 workers you can use:
#!/bin/sh
for x in `seq 1 10` ; do
screen -dmS worker_$x php /path/to/script.php worker$x
end
This will start 10 workers in the background using screens named worker_1,2,3 and so on.
You can reattach to the screens by running screen -r worker_ and list the running workers by using screen -list.
For more info this guide may be of help: http://www.kuro5hin.org/story/2004/3/9/16838/14935
Also try:
For production servers I would normally recommend using the normal system startup scripts, but I have been running screen commands from the startup scripts for years with no problems.