Running Meteor Forever

December 01, 2013

Recently I’ve decided to learn Meteor JS, which is an “open-source platform for building top-quality web apps in a fraction of the time.” It’s super fast (i.e. great for hackathons) to get an application up and running. I’ve only been using Meteor for a couple of days but love it so far and possibly will consider using it instead of my current favorite Play Framework.

One issue I encountered when deploying my application to production was that once I started the app on my server using “meteor &” I noticed the application would die after I exited the terminal. This is actually a common “issue” in the NodeJS world and many posts have suggested the use of the NPM Forever tool for running a Meteor bundle even when you exit the terminal session. One StackOverflow post showed the following commands:

export MONGO_URL=mongodb://localhost:27017/<dbname>
export PORT=<server_port>
export ROOT_URL=
forever start bundle/main.js

Unfortunately this didn’t work for me but bsilvereagle from the Meteor IRC channel suggested I create a tmux session, start my Meteor server in it, and detach the session. So, you would roughly run the following commands:

# a new tmux session will be created and you'll notice a green bar at the bottom of the terminal
# start your Meteor app: (e.g. "meteor &amp;")
# press CLTR and B, :, and "detach" to detach the session
# Type "tmux list-sessions" to see the session you just created 
# You can join your session by typing "tmux attach-session -t <number>"

Now Meteor will run even if I exit from my terminal. Yay!

Hopefully this helps someone out there but here’s a couple more tmux resources: