2 # /etc/init.d/mediagoblin-paster
4 ## LICENSE: CC0 <http://creativecommons.org/publicdomain/zero/1.0/>
5 # To the extent possible under law, Joar Wandborg <http://wandborg.se> has
6 # waived all copyright and related or neighboring rights to
7 # mediagoblin-paster. This work is published from Sweden.
10 # Credit goes to jpope <http://jpope.org/> and
11 # chimo <http://chimo.chromic.org/>. From which' Arch init scripts this is
15 # Provides: mediagoblin-paster
16 # Required-Start: $network $named $local_fs
17 # Required-Stop: $remote_fs $syslog $network $named $local_fs
18 # Should-Start: postgresql $syslog
19 # Default-Start: 2 3 4 5
21 # Short-Description: MediaGoblin paster FCGI server init script
22 # Description: This script will initiate the GNU MediaGoblin paster
26 ################################################################################
28 # to suit your environment
29 ################################################################################
30 MG_ROOT=/srv/mediagoblin
31 ################################################################################
33 # You probably won't have to change anything else.
34 ################################################################################
38 DAEMON_NAME=mediagoblin-paster
41 MG_PASTER_BIN=$MG_BIN/paster
42 MG_PASTE_INI=$MG_ROOT/paste_local.ini
44 MG_FCGI_HOST=127.0.0.1
46 MG_PASTER_PID_FILE=/var/run/mediagoblin/$DAEMON_NAME.pid
47 MG_PASTER_LOG_FILE=/var/log/mediagoblin/$DAEMON_NAME.log
49 set_up_directories() {
50 install -o $MG_USER -g users -d -m 755 /var/log/mediagoblin
51 install -o $MG_USER -g users -d -m 755 /var/run/mediagoblin
56 # Include LSB helper functions
57 . /lib/lsb/init-functions
60 # Discard any errors from cat
61 cat $MG_PASTER_PID_FILE 2>/dev/null
66 # Start the MediaGoblin paster process
67 log_daemon_msg "Starting GNU MediaGoblin paster fcgi server" "$DAEMON_NAME"
68 if [ -z "$(getPID)" ]; then
69 su -s /bin/sh -c "CELERY_ALWAYS_EAGER=False $MG_PASTER_BIN serve \
72 fcgi_host=$MG_FCGI_HOST fcgi_port=$MG_FCGI_PORT \
73 --pid-file=$MG_PASTER_PID_FILE \
74 --log-file=$MG_PASTER_LOG_FILE \
75 --daemon" - $MG_USER 2>&1 > /dev/null
79 # Sleep for a while until we're kind of certain that paster has
80 # had it's time to initialize
82 while ! [ "X$PASTER_RESULT" != "X" ]; do
83 log_action_msg "Tried $TRIES time(s)"
88 log_end_msg $PASTER_RESULT
90 # Failed because the PID file indicates it's running
91 log_action_msg "PID file $MG_PASTER_BIN already exists"
96 log_daemon_msg "Stopping GNU MediaGoblin paster fcgi server" "$DAEMON_NAME"
97 if [ -z "$(getPID)" ]; then
98 # Failed because the PID file indicates it's not running
103 if [ $? -gt 0 ]; then
117 if ! [ -z "$(getPID)" ]; then
118 echo "$DAEMON_NAME start/running, process $(getPID)"
120 echo "$DAEMON_NAME stopped."
124 echo "Usage: $0 {restart|start|stop|status}"