janemchu
By:
janemchu

Why is my upstart file not starting my MeteorJS app?

April 6, 2015 2.3k views
Nginx DigitalOcean

I am on Ubuntu 14.04 and I have an upstart file angular-meteor.conf with the following:

# upstart service file at /etc/init/angular-meteor.conf
description "Meteor.js (NodeJS) application"

# When to start the service
start on runlevel [2345]

# When to stop the service
stop on shutdown

# Automatically restart process if crashed
respawn

# Let upstart know the process will detach itself to the background
expect fork

# start meteor
exec meteor

This is not working, I have tried a few variations eg. http://stackoverflow.com/questions/15657071/how-to-run-meteor-on-startup-on-ubuntu-server

Anyone know why it wouldn't be working? I know that it is starting at least.

1 comment
  • When I try this example I get this in the /var/log/upstart/myapp.log file:

    There is no /root/myapp/.meteor/meteor file, only the one in /usr/local/bin/meteor

    The app is telescope http://telescopeapp.org


    '/root/myapp/.meteor' exists, but '/root/myapp/.meteor/meteor' is not executable.

    Remove it and try again.

    '/root/myapp/.meteor' exists, but '/root/myapp/.meteor/meteor' is not executable.

    Remove it and try again.

    '/root/myapp/.meteor' exists, but '/root/myapp/.meteor/meteor' is not executable.

    Remove it and try again.

2 Answers

Add the following lines to your upstart script:

setuid user to run as
setgid group to run as, usually the same as the user
chdir /path/to/meteor_app

Then try starting it. Does that work? If not, take a look at the log file and see if there are any errors:

sudo tail /var/log/upstart/angular-meteor.log
  • Hi Kamain,

    I have added your comments and meteor runs, however it starts up mongodb even though MONGOURL has been set in .bashprofile. I have tried re-setting it inside the .conf but it still starts it up, it does not do this when i just run meteor normally out of the app folder.

    # When to start the service
    start on runlevel [2345]
    
    # When to stop the service
    stop on shutdown
    
    # Automatically restart process if crashed
    respawn
    
    # Set user id, group for user id
    setuid root
    setgid root
    
    chdir /var/www/meteor/html/angular-meteor
    
    env USER='root'
    env HOME='/usr/local/bin'
    
    expect fork
    
    export MONGO_URL='mongodb://localhost:27017/drupal'
    
    exec /usr/local/bin/meteor -p 80
    

    Thanks for your suggestions!

  • Everything is working now, for anyone interested, the other issue I had with mongo starting up from meteor is now resolved by using a shell script to set MONGOURL.

    cd /path/to/app
    export MONGO_URL='mongodb://localhost:27017/db_name'
    /path/to/meteor -p 80
    
Have another answer? Share your knowledge.