#!upstart
description "node.js based server"
author      "Alexey Zhurbitsky <zhurbitsky@gmail.com>"

#start on net-device-up
start on (started networking)
stop on starting shutdown

respawn
respawn limit 10 10

script

    sleep 30

    export HOME="/root"

    if [ ! -d /var/log/stalkerd ]
    then
        mkdir -m 755 /var/log/stalkerd
        chown www-data:www-data /var/log/stalkerd
    fi

    exec sudo -u www-data /usr/local/bin/node @STALKERD_INDEX_PATH@ 1>>/var/log/stalkerd/access.log 2>>/var/log/stalkerd/error.log

end script