-
Notifications
You must be signed in to change notification settings - Fork 2
foreman export procfile to upstart
Upstart is an event-based replacement for the /sbin/init daemon which handles starting of tasks and services during boot, stopping them during shutdown and supervising them while the system is running.
It was originally developed for the Ubuntu distribution, but is intended to be suitable for deployment in all Linux distributions as a replacement for the venerable System-V init.
Doing an ls in the /etc/init folder will show several services that were set up during the system installation (e.g. Ubuntu), and these instructions are just adding a new upstart service to handle Resque, Resque Scheduler, and possibly Thin.
cd /home/rails-app-user/apps/osprotect
Located in this folder are several example Procfiles.
worker: bundle exec rake resque:work QUEUE=*
scheduler: bundle exec rake resque:scheduler
ensure the file is saved with the name Procfile, as this is what foreman is looking for by default.
- if ruby from source:
sudo bundle exec foreman export upstart /etc/init -a osprotect -d /home/rails-app-user/apps/osprotect -u rails-app-user -c worker=3,scheduler=1
... or ...
- if ruby via rvm:
rvmsudo bundle exec foreman export upstart /etc/init -a osprotect -d /home/rails-app-user/apps/osprotect -u rails-app-user -c worker=3,scheduler=1
now view the results in the /etc/init folder:
ls /etc/init
... the output should be similar to:
osprotect.conf
osprotect-scheduler.conf
osprotect-scheduler-1.conf
osprotect-worker.conf
osprotect-worker-1.conf
osprotect-worker-2.conf
osprotect-worker-3.conf
it is now possible to start/stop the Resque workers and scheduler using these commands:
sudo service osprotect stop
sudo service osprotect start
See the bottom of this page for instructions on how to enable this service to start on server reboot.
web: bundle exec thin start -p $PORT
worker: bundle exec rake resque:work QUEUE=*
scheduler: bundle exec rake resque:scheduler
ensure the file is saved with the name Procfile, as this is what foreman is looking for by default.
- if ruby from source:
sudo bundle exec foreman export upstart /etc/init -a osprotect -d /home/rails-app-user/apps/osprotect -u rails-app-user -c web=3,worker=3,scheduler=1
... or ...
- if ruby via rvm:
rvmsudo bundle exec foreman export upstart /etc/init -a osprotect -d /home/rails-app-user/apps/osprotect -u rails-app-user -c web=3,worker=3,scheduler=1
now view the results in the /etc/init folder:
ls /etc/init
... the output should be similar to:
osprotect.conf
osprotect-web.conf
osprotect-web-1.conf
osprotect-web-2.conf
osprotect-web-3.conf
osprotect-worker.conf
osprotect-worker-1.conf
osprotect-worker-2.conf
osprotect-worker-3.conf
osprotect-scheduler.conf
osprotect-scheduler-1.conf
it is now possible to start/stop the Thin app servers, and the Resque workers and scheduler using these commands:
sudo service osprotect stop
sudo service osprotect start
See the bottom of this page for instructions on how to enable this service to start on server reboot.
To start osprotect services at boot do:
sudo nano /etc/init/osprotect.conf
then add the following line to the top of the file:
start on runlevel [2345]
then save, and now anytime the server is rebooted the osprotect services will start.
Also, a nice benefit of using Upstart is that it will monitor these services and if any are killed/die then it will restart them.