Created
December 5, 2011 19:29
-
-
Save chapmanb/1434908 to your computer and use it in GitHub Desktop.
Example Galaxy start script for CentOS: edit and put in /etc/init.d/galaxy
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
#--- config | |
SERVICE_NAME=galaxy | |
RUN_AS=galaxy | |
RUN_IN=/your/galaxy/directory | |
#--- main actions | |
start() { | |
echo "Starting $SERVICE_NAME... " | |
cmd="cd $RUN_IN && sh run.sh --daemon" | |
case "$(id -un)" in | |
$RUN_AS) | |
eval "$cmd" | |
;; | |
root) | |
su - $RUN_AS -c "$cmd" | |
;; | |
*) | |
echo "*** ERROR *** must be $RUN_AS or root in order to control this service" >&2 | |
exit 1 | |
esac | |
echo "...done." | |
} | |
stop() { | |
echo -n "Stopping $SERVICE_NAME... " | |
cmd="cd $RUN_IN && sh run.sh --stop-daemon" | |
case "$(id -un)" in | |
$RUN_AS) | |
eval "$cmd" | |
;; | |
root) | |
su - $RUN_AS -c "$cmd" | |
;; | |
*) | |
echo "*** ERROR *** must be $RUN_AS or root in order to control this service" >&2 | |
exit 1 | |
esac | |
echo "done." | |
} | |
status() { | |
echo -n "$SERVICE_NAME status: " | |
while read pid; do | |
if [ "$(readlink -m /proc/$pid/cwd)" = "$(readlink -m $RUN_IN)" ]; then | |
echo "started" | |
return 0 | |
fi | |
done < <(ps ax -o 'pid cmd' | grep -P '^\s*\d+ python ./scripts/paster.py serve' | awk '{print $1}') | |
echo "stopped" | |
return 3 | |
} | |
notsupported() { | |
echo "*** ERROR*** $SERVICE_NAME: operation [$1] not supported" | |
} | |
usage() { | |
echo "Usage: $SERVICE_NAME start|stop|restart|status" | |
} | |
#--- | |
case "$1" in | |
start) | |
start "$@" | |
;; | |
stop) | |
stop | |
;; | |
restart|reload) | |
stop | |
start | |
;; | |
status) | |
set +e | |
status | |
exit $? | |
;; | |
'') | |
usage >&2 | |
exit 1 | |
;; | |
*) | |
notsupported "$1" >&2 | |
usage >&2 | |
exit 1 | |
;; | |
esac |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment