Skip to content

Instantly share code, notes, and snippets.

@chaitu87
Created July 29, 2014 17:15
Show Gist options
  • Save chaitu87/bf08fa1eefdb2e1f3de4 to your computer and use it in GitHub Desktop.
Save chaitu87/bf08fa1eefdb2e1f3de4 to your computer and use it in GitHub Desktop.
phantomjs as service
# Place the file in /etc/init.d/ and reboot
# create for a prerender
description 'phantomjs'
start on runlevel [2345]
stop on runlevel [06]
respawn
# in case of failure retry 3 times to respawn with 5 sec interval
respawn limit 3 5
# set some variables
env SERVER=server.js
env HOST=http://fitternity.com
env PORT=9090
# enable logger output and write to syslog with tag phantomjs
# for more info see http://upstart.ubuntu.com/cookbook/#id152
# and/or type logger --help
console output
# execute the command and log it
script
cd /home/ubuntu/
exec phantomjs --disk-cache=no $SERVER $PORT http://www.fitternity.com | logger -s -t "phantomjs: "
end script
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment