Skip to content

Instantly share code, notes, and snippets.

@fredcy
Last active December 4, 2015 04:51
Show Gist options
  • Save fredcy/c1007573e1b5574cae8b to your computer and use it in GitHub Desktop.
Save fredcy/c1007573e1b5574cae8b to your computer and use it in GitHub Desktop.
#!/bin/bash
SITEHOME=/home/fred/elm/platform/Elm-Platform/master/elm-lang.org
PROG=dist/build/run-elm-website/run-elm-website
NAME=elm-website
PATH=/usr/local/bin:/home/fred/.cabal/bin:$PATH
LOGFILE=/var/log/${NAME}.log
# need this to avoid error about "hGetContents: invalid argument
# (invalid byte sequence)"
export LANG=en_US.UTF-8
# Once got an elm error when this was not set. Might not be needed anymore.
export HOME=/root
case $1 in
start)
echo $$ > /var/run/${NAME}.pid;
cd $SITEHOME
date >>$LOGFILE
exec $SITEHOME/$PROG 1>>$LOGFILE 2>&1
;;
stop)
kill `cat /var/run/${NAME}.pid` ;;
*)
echo "usage: elm-website {start|stop}" ;;
esac
exit 0
# /etc/monit/conf.d/elm-website.conf
check process elm-website with pidfile /var/run/elm-website.pid
start program = "/usr/local/sbin/elm-website start"
stop program = "/usr/local/sbin/elm-website stop"
if failed host 127.0.0.1 port 8000 protocol http
and request "/" with timeout 10 seconds then restart
if 5 restarts within 5 cycles then timeout
@ivanoats
Copy link

ivanoats commented Dec 4, 2015

Rock on. Thanks so much for setting this up! 🍰

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