Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to run meteor on startup on Ubuntu server

I learn meteorjs and I have a small remote VPS.

I want:

  1. Set auto pulling from git repository my meteor project.
  2. Put script into auto start which run my meteor project as service.

For example

meteor run -p 80 -- production

My server is Ubuntu 12.04

like image 866
Igor Shubin Avatar asked Mar 27 '13 10:03

Igor Shubin


1 Answers

You should use Ubuntu way, which is Upstart:

http://upstart.ubuntu.com/ http://manpages.ubuntu.com/manpages/lucid/man5/init.5.html

How to define daemon job:

http://newcome.wordpress.com/2012/02/26/running-programs-as-linux-daemons-using-upstart/

Hope it helps :)

Your upstart file would be more or less:

# meteorjs - meteorjs job file

description "MeteorJS"
author "Igor S"

# 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

# Run before process
pre-start script
        cd PATH_TO_METEOR_APP
        echo ""
end script

# Start the process
exec meteor run -p 80 --help -- production
like image 175
bluszcz Avatar answered Oct 01 '22 18:10

bluszcz