Skip to content

Instantly share code, notes, and snippets.

@philcryer
Forked from mattsgarrison/hubot_service.sh
Last active April 10, 2018 21:04
Show Gist options
  • Save philcryer/d391b72511f4b69cece3 to your computer and use it in GitHub Desktop.
Save philcryer/d391b72511f4b69cece3 to your computer and use it in GitHub Desktop.
Start/Stop script to manage Hubot (with Slack support) with Monit
#!/bin/sh
### BEGIN INIT INFO
# Provides: hubot
# Required-Start: $all
# Required-Stop: $all
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: starts the hubot service
# Description: starts the Hubot bot for the Campfire rooms
### END INIT INFO
USER="bot"
GROUP="bot"
NAME="chatbot"
HUBOT_HOME="/home/bot/hubot"
DAEMON="$HUBOT_HOME/bin/hubot"
LOGFILE="$HUBOT_HOME/hubot.log"
PIDFILE="$HUBOT_HOME/hubot.pid"
HUBOT_SLACK_TOKEN=xoxb-1234-5678-91011-00e4dd
DAEMON_OPTS="-a slack"
set -e
case "$1" in
start)
echo -n "Starting $NAME: "
start-stop-daemon --start -v --chdir $HUBOT_HOME --pidfile $PIDFILE -c $USER:$GROUP --make-pidfile --background --exec $DAEMON -- $DAEMON_OPTS
echo $PIDFILE
;;
stop)
echo -n "Stopping $NAME: "
start-stop-daemon --stop --pidfile $PIDFILE
echo $PIDFILE
;;
restart)
echo -n "Restarting $NAME: "
start-stop-daemon --stop --pidfile $PIDFILE
start-stop-daemon --start -v --chdir $HUBOT_HOME --pidfile $PIDFILE -c $USER:$GROUP --make-pidfile --background --exec $DAEMON -- $DAEMON_OPTS
echo $PIDFILE
;;
*)
N=/etc/init.d/$NAME
echo "Usage: $N {start|stop}" >&2
exit 1
;;
esac
exit
@guillain
Copy link

Thanks :-)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment