dracoblue.net

Run Jekyll as Upstart/Monit Service

When using jekyll to generate a static page, I wanted to have jekyll running as a service (by using upstart and monit).

Usually you launch jekyll with the --watch parameter and it will refresh the page continously.

Setup a upstart file called /etc/init/jekyll.conf.

script
    export LANG="en_US.UTF-8"
    exec start-stop-daemon --make-pid --start --pidfile /var/run/jekyll.pid --chdir /home/dracoblue/live/ --chuid dracoblue:dracoblue --exec /usr/bin/jekyll -- build --watch
end script

It's very important to have export LANG="en_US.UTF-8" in this definition, because otherwise jekyll uses US-ASCII and you can't get rid of messages like:

Liquid Exception: invalid byte sequence in US-ASCII in

Now you can stop/start your jekyll server like this:

 start jekyll

or

 stop jekyll

The corresponding monit file called /etc/monit/conf.d/jekyll.monitrc looks like this:

check process jekyll
    with pidfile "/var/run/jekyll.pid"
    start program = "/sbin/start jekyll"
    stop program = "/sbin/stop jekyll"
    if 2 restarts within 3 cycles then timeout
    if totalmem > 2000 Mb then alert
    if children > 255 for 5 cycles then stop
    if cpu usage > 95% for 3 cycles then restart

Finally restart monit:

/etc/init.d/monit restart

In jekyll, monit, ubuntu, upstart by @ 03 Dec 2013

comments powered by Disqus

Recent Files

Advertisement

Recent Dev-Articles

Read recently

About

Blogroll