How to run meteor when running on an Ubuntu server

I study meteorites and I have a small remote VPS.

I want:

  • Set automatic pulling of the meteor project from the git repository.
  • Put the script in an automatic run that starts my meteor project as a service.

for example

meteor run -p 80 -- production 

My Ubuntu 12.04 Server

+7
source share
3 answers

You should use the Ubuntu method, which is Upstart:

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

How to determine the task of the demon:

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

Hope this helps :)

Your upstart file will 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 
+13
source

That's what I'm doing:

 description "meteor app server" start on runlevel [2345] stop on runlevel [06] respawn respawn limit 10 5 pre-start script set -e rm -f /path/to/your/app/.meteor/local/db/mongod.lock end script exec /bin/su - ec2-user -c '/path/to/your/app/meteor_server.sh' post-stop script pkill -f meteor end script 

meteor_server.sh script contains:

 cd /path/to/your/app/; meteor run -p 3000 --production 

Make sure chmod +x meteor_server.sh script and change the path to your application in three places. The script also kills all meteor tasks when it is stopped, so it works to run a single meteorite application only on your server. I got a meteorite app that starts quickly using nginx, but node seems to be consuming a lot of memory.

+4
source

This is my meteorjs.conf file - it works fine. I used to describe problems, but this option fixed them. Hope this helps someone :)

All EXPORT variables I received from printenv

 # meteorjs - meteorjs job file description "MeteorJS" author "Alex Babichev" # 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/dev/www/test script export MONGO_URL=mongodb://localhost:27017/meteor export PATH=/opt/local/bin:/opt/local/sbin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin export PWD=/home/sputnik export NODE_PATH=/usr/lib/nodejs:/usr/lib/node_modules:/usr/share/javascript export HOME=/home/sputnik echo "---- start ----" cd /home/dev/www/test exec mrt end script 
+1
source

All Articles