forever Upstart job for UBUNTU

Below is the upstart job for ubuntu for eg: create a file in /etc/init/test.conf and copy the below content to test.conf file, and change path to your app.js to yours, 



#!upstart
description "node.js server"
author      "kirthan shetty"

start on runlevel [2345] and started networking
stop on runlevel [!2345] or  stopped networking
expect fork

script
    export HOME="/root"

    echo $$ > /var/run/yourprogram.pid
    exec sudo -u root PORT=3004 /usr/bin/node /path to your app.js >> /var/log/yourprogram.sys.log 2>&1
end script

pre-start script
    # Date format same as (new Date()).toISOString() for consistency
    echo "[`date -u +%Y-%m-%dT%T.%3NZ`] (sys) Starting" >> /var/log/yourprogram.sys.log
end script

pre-stop script
    rm /var/run/yourprogram.pid
    echo "[`date -u +%Y-%m-%dT%T.%3NZ`] (sys) Stopping" >> /var/log/yourprogram.sys.log
end script





to start #service test start
to stop # service test stop

No comments:

Post a Comment

Start and Stop ssh-agent

Below is the bash script used to start and stop ss-agent #!/bin/bash ## in .bash_profile SSHAGENT=`which ssh-agent` SSHAGENTARGS="...