0

I was wondering whether it is possible to have multiple php worker with upstart. My problem is that one worker isn't enough for my tasks anymore so I'd love to have 2-3 worker. Even better would be to automatically scale the number of workers.

I'm using:

# Info
description "My PHP Worker"
author      "Jonathan"

# Events
start on startup
stop on shutdown

# Automatically respawn
respawn
respawn limit 20 5

# Run the script!
# Note, in this example, if your PHP script returns
# the string "ERROR", the daemon will stop itself.
script
    [ $(exec /usr/bin/php -f /path/to/your/script.php) = 'ERROR' ] && ( stop; exit 1; )
end script

Found at Run php script as daemon process thx @Jonathan

Community
  • 1
  • 1
Manuel
  • 9,112
  • 13
  • 70
  • 110

1 Answers1

0

Basically, have one instance job with no start on and a stop on as stop-myworkers. Then have another job which starts a few workers with different instance ids at boot in a pre-start script and emits the aforementioned stop event on shutdown.

CameronNemo
  • 616
  • 3
  • 10