I'm a newbie on upstart, I didn't send the link just to make you busy :P

I did a fast read of the document and I think I came across a section where 
they describe your exact problem and how you should define the upstart. I can't 
help you more than this :)

-- 
Diogo Resende


On Monday, March 19, 2012 at 13:40 , HG wrote:

> Hi!
> 
> No, I hadn't - never stumbled across it as I'm running redhat. Looks good but 
> very extensive. If you know what I'm doing wrong, can you point it out? From 
> that cookbook I tried to do it like said on the Changing User section, but 
> the start-stop-daemon seems to be missing from redhat - I got error saying 
> that it's not found. So I'm stuck with the su solution, but it just isn't 
> working. So, this (what I have below) doesn't work:
> 
> exec su --session-command="/usr/local/bin/node 
> /home/nodeuser/dev/NodeApp/NodeApp-4.js" >> /var/log/NodeApp.log 2>&1 
> nodeuser &
> 
> And I cannot figure out why. It starts the node app, but the pid gets screwed 
> up. I tried to change it to following form from the cookbook:
> 
> exec su -c "/usr/local/bin/node /home/nodeuser/dev/NodeApp/NodeApp-4.js >> 
> /hugo/nodeuser/dev/NodeApp/NodeApp.log 2>&1" nodeuser
> 
> But that doesn't even start. So, I'm kind of stuck. I would really appreciate 
> if you could point out my error. Thanks.
> 
> 
> 
> On Mon, Mar 19, 2012 at 2:32 PM, Diogo Resende <[email protected] 
> (mailto:[email protected])> wrote:
> >  Have you read this?
> > 
> > http://upstart.ubuntu.com/cookbook/
> > 
> >  It's very good..
> > 
> >  --
> >  Diogo Resende
> > 
> > 
> >  On Monday, March 19, 2012 at 12:26 , HG wrote:
> > 
> > > Hi!
> > > 
> > > Can you tell me what I'm doing wrong. I'm trying to deploy to Redhat 6.1 
> > > using upstart. If I do it as root, it works, but I cannot get it done as 
> > > a user. It always tries to start multiple instances of the node process 
> > > when I run this /etc/init/NodeApp.conf script:
> > > 
> > > #!upstart
> > > description "node.js HTTP-server"
> > > author "me"
> > > 
> > > # One example said that it's safer to start after mounts
> > > #start on startup
> > > start on started mountall
> > > stop on shutdown
> > > 
> > > # respawn
> > > respawn
> > > # If the process is respawed more than 3 times within an interval of 10 
> > > seconds the process will be stopped and not restarted
> > > respawn limit 3 10
> > > 
> > > script
> > >  export NODE_ENV="production"
> > > 
> > >  # Somebody wrote: Not sure why $HOME is needed, but we found that it is:
> > >  export HOME="/home/nodeuser/"
> > > 
> > >  echo $$ > /var/run/NodeApp.pid
> > >  # sudo doesn't work on redhat
> > >  # exec sudo -u nodeuser /usr/local/bin/node 
> > > /home/nodeuser/dev/NodeApp-4.js >> /var/log/NodeApp.log 2>&1
> > >  exec su --session-command="/usr/local/bin/node 
> > > /home/nodeuser/dev/NodeApp/NodeApp-4.js" >> /var/log/NodeApp.log 2>&1 
> > > nodeuser &
> > > 
> > >  ### Why does this run spawnlimit+1 times at the startup ?!?
> > > 
> > >  # root works:
> > >  #echo $$ > /var/run/NodeApp.pid
> > >  #export HOME="/root"
> > >  #exec /usr/local/bin/node /home/nodeuser/dev/NodeApp/NodeApp-4.js >> 
> > > /var/log/NodeApp.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/NodeApp.log
> > > end script
> > > 
> > > pre-stop script
> > >  rm /var/run/NodeApp.pid
> > >  echo "[`date -u +%Y-%m-%dT%T.%3NZ`] (sys) Stopping" >> 
> > > /var/log/NodeApp.log
> > > end script
> > > 
> > > 
> > > The problem is that when I issue: sudo start NodeApp this starts the 
> > > process 4 times (spawnlimit+1). First one of those, will get the http 
> > > port and the rest will fail as the port is already taken. And as the 
> > > result of that, the NodeApp,pid file has the las PID which failed and the 
> > > first one that is running is not recorded. If I run this as root 
> > > (commented out), this works as expected. What am I doing wrong?
> > > 
> > > --
> > > HG.
> > > 
> > >  --
> > >  Job Board: http://jobs.nodejs.org/
> > >  Posting guidelines: 
> > > https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
> > >  You received this message because you are subscribed to the Google
> > >  Groups "nodejs" group.
> > >  To post to this group, send email to [email protected] 
> > > (mailto:[email protected]) (mailto:[email protected])
> > >  To unsubscribe from this group, send email to
> > > [email protected] 
> > > (mailto:nodejs%[email protected]) 
> > > (mailto:[email protected] 
> > > (mailto:nodejs%[email protected]))
> > >  For more options, visit this group at
> > > http://groups.google.com/group/nodejs?hl=en?hl=en
> > 
> > 
> >  --
> >  Job Board: http://jobs.nodejs.org/
> >  Posting guidelines: 
> > https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
> >  You received this message because you are subscribed to the Google
> >  Groups "nodejs" group.
> >  To post to this group, send email to [email protected] 
> > (mailto:[email protected])
> >  To unsubscribe from this group, send email to
> > [email protected] 
> > (mailto:nodejs%[email protected])
> >  For more options, visit this group at
> > http://groups.google.com/group/nodejs?hl=en?hl=en
> 
> 
> 
> -- 
> HG.
>  -- 
>  Job Board: http://jobs.nodejs.org/
>  Posting guidelines: 
> https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
>  You received this message because you are subscribed to the Google
>  Groups "nodejs" group.
>  To post to this group, send email to [email protected] 
> (mailto:[email protected])
>  To unsubscribe from this group, send email to
> [email protected] 
> (mailto:[email protected])
>  For more options, visit this group at
> http://groups.google.com/group/nodejs?hl=en?hl=en


-- 
Job Board: http://jobs.nodejs.org/
Posting guidelines: 
https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
You received this message because you are subscribed to the Google
Groups "nodejs" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/nodejs?hl=en?hl=en

Reply via email to