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
=GMG_PATH_TOKEN
/mediagoblin
32 ################################################################################
34 # You probably won't have to change anything else.
35 ################################################################################
39 DAEMON_NAME
=mediagoblin-paster
42 MG_PASTER_BIN
=$MG_BIN/paster
43 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 [ ! -f $MG_PASTE_INI ]; then
69 MG_PASTE_INI
=$MG_ROOT/paste.ini
71 if [ -z "$(getPID)" ]; then
72 su
-s /bin
/sh
-c "CELERY_ALWAYS_EAGER=False $MG_PASTER_BIN serve \
75 fcgi_host=$MG_FCGI_HOST fcgi_port=$MG_FCGI_PORT \
76 --pid-file=$MG_PASTER_PID_FILE \
77 --log-file=$MG_PASTER_LOG_FILE \
78 --daemon" - $MG_USER 2>&1 > /dev
/null
82 # Sleep for a while until we're kind of certain that paster has
83 # had it's time to initialize
85 while ! [ "X$PASTER_RESULT" != "X" ]; do
86 log_action_msg
"Tried $TRIES time(s)"
91 log_end_msg
$PASTER_RESULT
93 # Failed because the PID file indicates it's running
94 log_action_msg
"PID file $MG_PASTER_BIN already exists"
99 log_daemon_msg
"Stopping GNU MediaGoblin paster fcgi server" "$DAEMON_NAME"
100 if [ -z "$(getPID)" ]; then
101 # Failed because the PID file indicates it's not running
106 if [ $?
-gt 0 ]; then
119 if ! [ -z "$(getPID)" ]; then
120 echo "$DAEMON_NAME start/running, process $(getPID)"
122 echo "$DAEMON_NAME stopped."
126 echo "Usage: $0 {restart|start|stop|status}"