Hi all,
Looking for advice.
We're about to deploy queue-workers, which are essentially a shell-script which calls the PHP binary which keeps running and polling the jobqueue for jobs. Each website that we deploy to a server will get a queue-worker. These workers (there will be multiple per server) need to be kept running and should be started on boot, etc.
Sound like an init-script for each worker would do the trick. My goal is to make it easy for developers to deploy new workers, i.e. they should be able to create a new init-script, pointing to the location of their shell-script, and be able to count on it getting deployed and started on the server.
In other words:
1. The developer writes a shell-script called queue.sh and deploys it in the root of the website's directory. The shell-script starts the php cli binary which keeps running until it's stopped or dies for some reason.
2. They call a single define in our Puppet code that takes the path to queue.sh as a parameter and ensures the init-script is created from a template.
3. The server picks up the init-script and starts managing the service.
3. The init-script takes care of running the queue.sh script at boot and can stop/restart it when needed.
4. Repeat for each website.
For the moment, we're on Ubuntu 14.04 so Upstart scripts would be a logical choice. In the future we'll move to Ubuntu 16.04, with systemd.
I created a define that we can add to a node manifest. Here's an example of how I imagine calling this define:
site::queueworker { 'website01': path => '/var/www/website01/queue.sh' }
This drops a new Upstart init-script in /etc/init/ based on a template:
/etc/init/queue-website01.conf
I'm unsure if/how I can immediately use this new Upstart service in a service, e.g.: service {'queue-website01': ensure => running, enable => true}. I mean, how do Puppet and the init system know about the new service?
Will that work, or am I going about this completely the wrong way? Should I be using supervised or something else instead?
Thanks for any advice you can give.
Martijn