1

I scheduled cron jobs for running project that developed with meteor when system boots on Debian 7 and Centous 6.5 . And everything was working good until to unknown reasons it crashed.

Cron contain command that run Rocket.Chat project that developed with meteor. When I run meteor command by ssh connection, Rocket.chat run until ssh connection was open.

And at the end I want to know how to run meteor or node.js project when system boots as that project does not crashed until system shutting down or kill cron.

majidfathi69
  • 1,689
  • 2
  • 17
  • 24
  • Can you show your crontab? It's hard to diagnose without a starting point. – David Weldon Feb 21 '16 at 15:12
  • @DavidWeldon My cron contained this command: `cd Rocket.Chat; meteor run`. I think accordding to [link](http://stackoverflow.com/questions/25677701/how-to-run-meteor-forever-and-is-it-good-using-3rd-party-database) I must do something to release project and run finial output in cron.? – majidfathi69 Feb 22 '16 at 05:59

3 Answers3

1

One good way to keep NodeJS apps running and starting at boot is to use PM2 (https://github.com/Unitech/pm2). Rocket.Chat even has an example configuration file on the root folder of the app.

Also, make sure you don't use the meteor command in production environment, it is only meant for development, as it has many debugging features that make the app much slower.

You should download the compiled versions from https://rocket.chat/releases/

0

To respond to your first issue, being meteor shutting down when your ssh connection died, you can always use nohup

 nohup meteor > /dev/null &

im setting /dev/null as output but if you specify a file there youll have a log of what usually gets printed into screen. When you disconnect your meteor will keep running :).

As of running a service on boot you dont really need cron you can create a script. If using Debian or debian based distro(as one of your tags implies) just copy the skeleton script

cp /etc/init.d/skeleton /etc/init.d/myCoolNodeProject

and edit your file with your environment on how start stop your nodejs service

then run

 update-rc.d myCoolNodeProject defaults

to set it to start on boot time. Hope it helps

jstuartmilne
  • 4,398
  • 1
  • 20
  • 30
0

There is an excellent tool called Passenger

https://www.phusionpassenger.com/

This allows you to set up an NGINX proxy to run all your meteor apps on port 80, and it looks after running the processes without the need for cron jobs and worrying about how to set up nohup.

Their help is good, and Passenger integrates so easily with the NGINX virtual host configs that you won't look back

Mikkel
  • 7,693
  • 3
  • 17
  • 31