Skip to content

Instantly share code, notes, and snippets.

@stretchkennedy stretchkennedy/oryx-batch

Last active Sep 30, 2015
Embed
What would you like to do?
SysVinit startup scripts for Cloudera Oryx 2, assuming that it's installed in /usr/local/oryx and a user "oryx" has access to it
#!/bin/sh
### BEGIN INIT INFO
# Provides: oryx-batch
# Required-Start: $local_fs $network $named $time $syslog
# Required-Stop: $local_fs $network $named $time $syslog
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Description: Oryx 2 distributed lambda architecture - batch component
### END INIT INFO
SCRIPT="cd /usr/local/oryx/ && ./oryx-run.sh batch"
RUNAS=oryx
PIDFILE=/var/run/oryx-batch.pid
LOGFILE=/var/log/oryx-batch.log
start() {
if [ -f $PIDFILE ] && kill -0 $(cat $PIDFILE); then
echo 'Service already running' >&2
return 1
fi
echo 'Starting service…' >&2
local CMD="$SCRIPT 1> \"$LOGFILE\" 2>&1 & echo \$!"
su -s /bin/sh -c "$CMD" $RUNAS > "$PIDFILE"
echo 'Service started' >&2
}
stop() {
if [ ! -f "$PIDFILE" ] || ! kill -0 $(cat "$PIDFILE"); then
echo 'Service not running' >&2
return 1
fi
echo 'Stopping service…' >&2
kill -15 $(cat "$PIDFILE") && rm -f "$PIDFILE"
echo 'Service stopped' >&2
}
case "$1" in
start)
start
;;
stop)
stop
;;
retart)
stop
start
;;
*)
echo "Usage: $0 {start|stop|restart}"
esac
### BEGIN INIT INFO
# Provides: oryx-serving
# Required-Start: $local_fs $network $named $time $syslog
# Required-Stop: $local_fs $network $named $time $syslog
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Description: Oryx 2 distributed lambda architecture - serving component
### END INIT INFO
SCRIPT="cd /usr/local/oryx/ && ./oryx-run.sh serving"
RUNAS=oryx
PIDFILE=/var/run/oryx-serving.pid
LOGFILE=/var/log/oryx-serving.log
start() {
if [ -f $PIDFILE ] && kill -0 $(cat $PIDFILE); then
echo 'Service already running' >&2
return 1
fi
echo 'Starting service…' >&2
local CMD="$SCRIPT 1> \"$LOGFILE\" 2>&1 & echo \$!"
su -s /bin/sh -c "$CMD" $RUNAS > "$PIDFILE"
echo 'Service started' >&2
}
stop() {
if [ ! -f "$PIDFILE" ] || ! kill -0 $(cat "$PIDFILE"); then
echo 'Service not running' >&2
return 1
fi
echo 'Stopping service…' >&2
kill -15 $(cat "$PIDFILE") && rm -f "$PIDFILE"
echo 'Service stopped' >&2
}
case "$1" in
start)
start
;;
stop)
stop
;;
retart)
stop
start
;;
*)
echo "Usage: $0 {start|stop|restart}"
esac
#!/bin/sh
### BEGIN INIT INFO
# Provides: oryx-speed
# Required-Start: $local_fs $network $named $time $syslog
# Required-Stop: $local_fs $network $named $time $syslog
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Description: Oryx 2 distributed lambda architecture - speed component
### END INIT INFO
SCRIPT="cd /usr/local/oryx/ && ./oryx-run.sh speed"
RUNAS=oryx
PIDFILE=/var/run/oryx-speed.pid
LOGFILE=/var/log/oryx-speed.log
start() {
if [ -f $PIDFILE ] && kill -0 $(cat $PIDFILE); then
echo 'Service already running' >&2
return 1
fi
echo 'Starting service…' >&2
local CMD="$SCRIPT 1> \"$LOGFILE\" 2>&1 & echo \$!"
su -s /bin/sh -c "$CMD" $RUNAS > "$PIDFILE"
echo 'Service started' >&2
}
stop() {
if [ ! -f "$PIDFILE" ] || ! kill -0 $(cat "$PIDFILE"); then
echo 'Service not running' >&2
return 1
fi
echo 'Stopping service…' >&2
kill -15 $(cat "$PIDFILE") && rm -f "$PIDFILE"
echo 'Service stopped' >&2
}
case "$1" in
start)
start
;;
stop)
stop
;;
retart)
stop
start
;;
*)
echo "Usage: $0 {start|stop|restart}"
esac
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.