Linode Forum
Linode Community Forums
 FAQFAQ    SearchSearch    MembersMembers      Register Register 
 LoginLogin [ Anonymous ] 
Post new topic  Reply to topic
Author Message
PostPosted: Mon Nov 26, 2012 6:36 am 
Offline
Newbie

Joined: Mon Nov 26, 2012 6:31 am
Posts: 3
I got my own linode server the other day and moved a small nodejs / express I was playing around with over from an aws linux. Everything works great, but if I launch the app with upstart it doesnt run with the right permissions and can't write files to disk. I tried all kinds of variations of the upstart script, as root, as my username, www-data and nothing works. I set the public directory of express to 777 even just as a test but no luck. I start my upstart job with sudo start now-images-manager. When I run ps -ef I get the following output:

Code:
root     25150     1  0 11:26 ?        00:00:00 sudo node /home/myusername/sites/now-images-manager/app.js
root     25151 25150  0 11:26 ?        00:00:03 node /home/myusername/sites/now-images-manager/app.js


Here is my upstart script:

Code:
#!upstart
description "now-images-manager startup script"
author      "me@me.com"

start on startup
stop on shutdown

script
    export HOME="/root"
    echo $$ > /var/run/now-images-manager.pid
    exec sudo node /home/myusername/sites/now-images-manager/app.js >> /home/myusername/sites/now-images-manager/now-images-manager.sys.log 2>&1
    # exec sudo -u myusername /usr/bin/node /home/myusername/sites/now-images-manager/app.js >> /home/myusername/sites/now-images-manager/now-images-manager.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/now-images-manager.sys.log
end script

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


Here is a sample from the log:

Code:
downloadFileFromURL  { [Error: ENOENT, open 'public/images/tumblr_m9h1uh4KSi1qzl9k6o1_500.jpg']
  errno: 34,
  code: 'ENOENT',
  path: 'public/images/tumblr_m9h1uh4KSi1qzl9k6o1_500.jpg' }
When I start the app with node app.js in the shell it works perfectly fine.


Top
   
PostPosted: Tue Nov 27, 2012 12:34 am 
Offline
Senior Member
User avatar

Joined: Sun Jan 18, 2009 2:41 pm
Posts: 830
ENOENT means "no such file or directory." It looks like your app is using a relative path to the file; is it possible it's not starting from the directory you think it is? If you run it by hand from the "right" directory, that may explain why it works then.


Top
   
PostPosted: Tue Nov 27, 2012 7:41 am 
Offline
Newbie

Joined: Mon Nov 26, 2012 6:31 am
Posts: 3
Vance, thanks so much for the reply. Fixed it. Should have noticed this myself!

Thomas


Top
   
Display posts from previous:  Sort by  
Post new topic  Reply to topic


Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Jump to:  
RSS

Powered by phpBB® Forum Software © phpBB Group