Running meteor as daemon even if server reboots

I have problems to understand how to run meteor as daemon.

I have built an application and I would like to run and release it in production on http://ip:port

Application works fine by meteor --production --port 3000 & and I can go around putty, but when I close it Meteor process dies.

I understand that Upstart would be a solution and I have seen that some Meteor developers has conf. files in /etc/init/

However, I cannot figure out how I could run meteor everytime server reboot or something - I have been spending one week straight on computer working with my application, so I feel I am having serious brainfog to understand certain things.

I have tried the following (/etc/init/myMeteorApplication.conf) running it by start myMeteorApplication and it looks that Ubuntu find the .conf file, but nothing really happens and cannot be found in service --status-all. Typing stop myMeteorApplication returns stop: Unknown instance:

/etc/init/myMeteorApplication.conf

start on runlevel [2345]
stop on runlevel [016]

respawn

pre-start script
        cd myMeteorDir
        echo ""
end script


exec meteor --help --production --port 3000

Remove this and try again.

Also, if you prepend nohup with meteor --production --port 3000 &, it won’t go away after you close putty:

nohup meteor --production --port 3000 &

You can also check the screen command.

@necmettin

regarding nohup

I got nohup working, it just requires that I exit from Putty and not just close it. How long will nohup will work? And how can it be terminated?

root@paisti:~/production/kaukalopallo# nohup meteor --production --port 3000 & [1] 11155 root@paisti:~/production/kaukalopallo# nohup: ignoring input and appending output to ‘nohup.out’

removing --help from .conf

Looks like removing --help did not work. Should I still receive Meteor starting log in Putty even using .conf file ?

ps ax | grep meteor | grep -v grep will give you process id for your command. Then you can kill _processId_.

I do not understanding the difference between exiting from Putty and closing it.

You will not receive a Meteor starting log in Putty with /etc/init or /etc/init.d. Try the ps ax | grep meteor | grep -v grep command, if you get a process id, that means it is working.

Also, when using Putty, Ctrl+D out of your connections to make sure you don’t leave the server hanging (even if it’s a tiny little bit of time). At least that was the case when I was on Windows (years ago).