Skip to content

Commit

Permalink
Adding init script
Browse files Browse the repository at this point in the history
  • Loading branch information
Unai Goikoetxeta authored and Unai Goikoetxeta committed Jul 13, 2015
1 parent 0ae05d3 commit 6cb9236
Show file tree
Hide file tree
Showing 3 changed files with 72 additions and 0 deletions.
Binary file added .DS_Store
Binary file not shown.
29 changes: 29 additions & 0 deletions extra/transcode-init.d/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
Celery Init script
==================
Having installed all the requirements for transcoding within WhatManager2, follow these steps to setup the init script for Ubuntu or Debian:

1. Install screen:

sudo apt-get install screen

2. Replace USERNAME in wm2celery with the username you wish Celery to run from.


3. Copy wm2celery to /etc/init.d/

4. Make sure it has execution rights:

sudo chmod +x /etc/init.d/wm2celery

5. Set the init script for boot time:

sudo update-rc.d wm2celery defaults



Once installed, the service will be handled the usual way:

sudo service wm2celery start | stop | restart


You will be able to reattach to the screen session that is running Celery using screen normally.
43 changes: 43 additions & 0 deletions extra/transcode-init.d/wm2celery
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
#!/bin/bash
# /etc/init.d/wm2celery

### BEGIN INIT INFO
# Provides: whatmanager2
# Required-Start: $local_fs $remote_fs
# Required-Stop: $local_fs $remote_fs
# Should-Start: $network
# Should-Stop: $network
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Run Celery for WhatManager2
# Description: Runs Celery on a detached screen session for WhatManager2.
### END INIT INFO

USER="USERNAME"

case "$1" in

start)
echo "Starting Celery for WhatManager2"
sudo -H -u $USER screen -dmS WM2Celery /usr/bin/python /opt/WhatManager2/manage.py celery worker --loglevel=info --concurrency=1
;;
stop)
echo "Stopping Celery for WhatManager2"
PID=`ps -ef | grep manage.py | grep pts | grep -v grep | awk '{print $2}'`
kill -9 $PID
;;

restart|force-reload)
echo "Restarting $screen"
PID=`ps -ef | grep manage.py | grep pts | grep -v grep | awk '{print $2}'`
kill -9 $PID
sleep 2
sudo -H -u $USER screen -dmS WM2Celery /usr/bin/python /opt/WhatManager2/manage.py celery worker --loglevel=info --concurrency=1
;;
*)
N=/etc/init.d/$NAME
echo "Usage: $N {start|stop|restart}" >&2
exit 1
;;
esac
exit 0

0 comments on commit 6cb9236

Please sign in to comment.