Running Meteor as a Service on Ubuntu 16.04 Using Systemd

When it comes to deploying Meteor and making sure that it’s running 100% of the time (turn it into a service / daemonise), there does not seem to be a straightforward answer that will work across all variants of Meteor and your OS flavours and versions.

I’ve had moderate success with Upstart on 14.04 but I realised Upstart had been deprecated in 16.04 in favour of systemd.

PM2 / pm2-meteor, Forever and other process managers didn’t really cut it for me. PM2 is great for vanilla Node.js scripts but pm2-meteor didn’t really work so well in this particular instance where the Meteor app was running on Meteor version 1.2. I did try and upgrade to 1.4 but ran into issues with Fabric.

Anyway, let’s get to the crux. Systemd is a nice way to make sure that your Meteor is always running. Let’s say the app is called foobar. Create a file at /etc/systemd/system/foobar.service  and paste the following in:

Just make sure WorkingDirectory and Environment=PWD points to the root directory of your Meteor app. Then:

This should do the trick. You should be able to reboot your instance (mine is an AWS EC2 running on Ubuntu 16.04.2 LTS) and see that your Meteor app is running automatically on startup.

You will be able to view the Meteor stdout logged in /var/log/syslog . Good luck!



  • Mike Acre

    May 18, 2018 at 2:23 am

    You rock!

Write a comment

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.