Hello World
Well this is pretty much your run-of-the-mill, dime-a-dozen, garden-variety, cliché “hello world”. It’s being transmitted to you, via the internet, in good old fashioned HTML. All that you see before you is being generated for your viewing pleasure by Jekyll.
Might as well make this useful, here’s the bash script I use to daemonize jekyll.
#!/bin/sh
# jekyll Starts and stops Jekyll
# copy and save me to /usr/local/bin/jekyll-daemon
#Where do you keep Jekyll?
JEKYLL_EXE=/usr/local/rvm/gems/ruby-2.2.1/bin/jekyll
#I use this find to search my vhosts for jekyll directories
SITES=$(find /var/www/vhosts/ -maxdepth 2 -type d -name jekyll)
#The Log File
LOG_FILE="/var/log/jekyll"
case "$1" in
start)
for f in $SITES
do
SOURCE="$f"
DEST="$f/../httpdocs/"
PID_FILE="/var/run/${f//\//_}.pid"
$JEKYLL_EXE build --source $SOURCE --destination $DEST --watch >> $LOG_FILE &
echo $! > $PID_FILE
echo "Jekyll STARTED: $f"
done
exit 0
;;
stop)
for f in $SITES
do
PID_FILE="/var/run/${f//\//_}.pid"
kill -TERM $(cat $PID_FILE)
rm -f $PID_FILE
echo "Jekyll Stopped: $f"
done
exit 0
;;
restart)
$0 stop
$0 start
exit 0
;;
status)
echo "Active Jekyll Daemons"
for f in $SITES
do
PID_FILE="/var/run/${f//\//_}.pid"
ps -p `cat $PID_FILE` > /dev/null 2>&1 && echo $(cat $PID_FILE) $f
done
;;
*)
echo "Usage: $0 {start|stop|restart|status}"
exit 1
esac
Original idea from [a github user] I made a few updates so it would run across my whole server, and I only have to restart it when I create a new vhost.
Update 23/06/2020: The original script author requested that I remove their name from this page.