How to start meteor on ubuntu boot

Hi, i need to start meteor environment at ubuntu startup.
I try to using ubuntu upstart with the following script:

# meteorjs - meteorjs job file

description "MeteorJS"
author "Simone M"

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

# When to stop the service
stop on runlevel [016]

# Automatically restart process if crashed
respawn

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

chdir /home/root/interactnew

script

#export MONGO_URL=mongodb://localhost:27017/meteor
#export PATH=/opt/local/bin:/opt/local/sbin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/u$
#export PWD=/home/root
#export NODE_PATH=/usr/lib/nodejs:/usr/lib/node_modules:/usr/share/javascript
export HOME=/home/root
export USER=root

echo "---- start ----"
cd /home/root/interactnew
exec meteor -p 3000
#exec su -s /bin/sh -c 'exec "$0" "$@"' root -- meteor -p 3000

end script

Script block at start… why?
In the end i need to start my application un folder “interactnew” using meteor enviroment.

Thx

Hi @moreschisimone

this is my always used upstart script. You have to apply your path information before use.

Please checkout there is this wait for mongod otherwise our apps sometimes could not be started and service ist stopping to fast while retry.

Good luck and thanks to some feedback.
Cheers, Tom


# meteor upstart script

description  "meteor service"

start on started mongodb and runlevel [2345]
stop on shutdown

console output

respawn
respawn limit unlimited

script
  # no log
  LOG_FILE=/dev/null
  # uncomment next line to save a log
  # LOG_FILE=/var/log/my-app.log

  # check and wait for connectable mongo
  MONGOSTAT=$(mongostat -n 1 2>&1) && true

  # test connection
  if [ "$?" != "0" ]
  then
    # wait some extra and exit to respawn
    sleep 5
    exit 1
  fi

  APP_DIR=/opt/my_app/bundle
  export PORT=80
  export MONGO_URL=mongodb://127.0.0.1/my_app
  export ROOT_URL=http://127.0.0.1

  exec /opt/node/bin/node "$APP_DIR/main.js" 2>&1 >> $LOG_FILE

end script

1 Like

Hi, thx for your response, but i need a method for start my app using meteor envirotment like:

/app-path/ meteor

And have it running on standard port 3000

Hi,

  1. you should may exchange the last exec command to what you need

and

  1. why do you need to run it via meteor when running as service? just make a meteor deploy --directory