yokodev
yokodev

Reputation: 1326

UPSTART script non root not working

I'm trying to run a nodejs application using upstart as a non root user.
But somehow parts of the script will not run : for instance:

  1. if I run it like a root user(below example) NODE_ENV never gets called/set
  2. the only way to called is with "sudo initctl stop pdcapp"
  3. sudo nameofApp start|stop would not work
  4. When called sudo initctl stop nameofApp the pre-stop script will not echo to the log file
  5. if I try to runit like a non root user it would not even start

isn't a more cleaner easier way of doing this (systemd) I've looked a various tutorials around and apparently this is how they've doneit. so what am I missing here?

This is the .conf file under /etc/init/

env FULL_PATH="/srv/pd/sept011100/dev"

env NODE_PATH="/usr/local/nodeJS/bin/node"
env NODE_ENV=production

start on filesystem or runlevel [2345]
stop on [!2345]

script
    export NODE_ENV #this variable is never set
    echo $$ > /var/run/PD.pid
    cd $FULL_PATH

    # the command below will not work  
    #exec sudo -u nginx "$NODE_PATH server.js >> /var/log/PD/pdapp.log 2>&1" 
    exec $NODE_PATH server.js >> /var/log/PD/pdapp.log 2>&1
end script

pre-start script
    echo "[`date`] (sys) Starting" >> /var/log/PD/pdapp.log
end script

pre-stop script
    rm /var/run/pdapp.pid
    echo "[`date`] (sys) Stopping" >> /var/log/PDC/pdapp.log
end script

in /var/log/messages I get this when I stop the application, otherwise I get nothing in the logfile

Sep  2 18:23:14 547610-redhat-dev2 init: pdcapp pre-stop process (6903) terminated with status 1
Sep  2 18:23:14 547610-redhat-dev2 init: pdcapp main process (6899) terminated with status 143

any Ideas why is this not working I'm running redhat 6.5

Upvotes: 1

Views: 565

Answers (1)

CameronNemo
CameronNemo

Reputation: 616

Red Hat has a super old version of Upstart that is probably full of bugs because they never contributed to Upstart, despite using it (Fedora switched to systemd right after RHEL 6 was released, before they even really tried it out well).

Upvotes: 1

Related Questions