Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I have a PHP script that waits for AMQP messages. When a message comes in it is processed and after processing is done it will wait for the next message.

The problem is of course that this is blocking. If e.g. an incoming message needs me to contact an external REST API, the processing could take several seconds to complete and all that time it won't be able to process other messages.

I can start my script several times, e.g. 8 times. This way I have 8 "consumers" and this seems to work very well. However, the problem now is, how do I manage these 8 different processes?

I basically looking for some utility that allows me to specify that I want to start a particular script 8 times and then to be able monitors these processes for up time etc. Is there such utility?

share|improve this question

1 Answer 1

Use upstart.

Edit /etc/init/whateveryouwant.conf

start on runlevel [2345]

task

env CONSUMERS=8

script
  for i in `seq 1 $CONSUMERS`
  do
    start /fullpath/to/your/script/here CONSUMER=$i
  done
end script
respawn limit 15 5

Then you can use service whateveryouwant start service whateveryouwant stop

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.