2

I've just setup a Linux CentOS server to run a Meteor application.

The first problem I come across now is starting the meteor process as a Daemon, so it's running in background and I can exit my SSH session.. When starting with meteor --production I can't.

When using Ruby on Rails I could just start with rails s -d -p 80 and exit.

I found out that an app called screen and echo "meteor --production" | at are options, but I do not have the at command installed, and installing an app just for running it in background seems like a weird choice.

Do I really need to install screen or at? Are there any other options?

Tim Baas
  • 6,035
  • 5
  • 45
  • 72
  • possible duplicate of [Keep meteor running on amazon EC2](http://stackoverflow.com/questions/21447818/keep-meteor-running-on-amazon-ec2) – David Weldon Apr 17 '14 at 19:07
  • have you tried `meteor --production &` ? The `&` at the end puts the job into the background. – Christian Fritz Apr 18 '14 at 03:08
  • The comment given by @ChristianFritz is misleading; `--production` is still development mode; just that the files are minified. You need to bundle Meteor, and run it as a daemon you would any node process. – Andrew Mao Apr 18 '14 at 03:24
  • @AndrewMao: that's sort of besides the point. While I agree with you in terms of bundling vs. `--production`, the OP specifically asked about it, and is really struggling with a linux issue of keeping processes started in a shell alive. This isn't about bundling or not. – Christian Fritz Apr 18 '14 at 03:57
  • @ChristianFritz backgrounding a process will cause it to exit when you quit the shell too, unless you `disown` in bash, for example. I would also suggest for the OP to use screen. – Andrew Mao Apr 18 '14 at 04:32
  • @ChristianFritz Though that would be a solution for me, because it's not really a problem it run in dev mode, it won't work, when I quit my shell the process is still stopped. – Tim Baas Apr 18 '14 at 07:33
  • @AndrewMao Screen is indeed a solution, also I tried tmux, but I couldn't get that to work.. After all my research I came to the conclusion that bundling is indeed a better option. After bundling I will use `pm2` to run it, it has lot's of great and usable extra functions too.. – Tim Baas Apr 18 '14 at 07:37

4 Answers4

1

Turns out theres no simple way to run an unbundled Meteor-app. There is always going to be other software involved like screen, tmux or at.

The duplicate of this question explains a lot about the process of running your app after it's bundled.

One piece of software that isn't mentioned there is pm2. I didn't use it yet, just installed it, but it seems like a really great tool to start the app in background and keep it running continuously.

Tim Baas
  • 6,035
  • 5
  • 45
  • 72
1

Meteor Up creates a daemon with these features:

  • Auto-Restart if the app crashed (using forever)

  • Auto-Start after the server reboot (using upstart)

Cees Timmerman
  • 17,623
  • 11
  • 91
  • 124
0

The Demeteorizer project may be a good option for you. It converts a Meteor project into a standard Node.js project.

You can get it at https://github.com/onmodulus/demeteorizer.

sheppe
  • 708
  • 5
  • 12
0

You can use the following shell command

$ ROOT_URL="http://yourserver.com" nohup meteor --production -p 8085 >meteor.log 2>meteor.error.log &

Replace 8085 with the port that you want to run it on. If you are running your own mongo instance and do not want to use meteor's bundled mongo, you can also add the MONGO_URL="mongodb://yourserver:port/"