Last active
December 4, 2015 04:51
-
-
Save fredcy/c1007573e1b5574cae8b to your computer and use it in GitHub Desktop.
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 | |
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 |
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
# /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 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Rock on. Thanks so much for setting this up! 🍰