Basically what i want to accomplish, is some sort of script or method for me to start a node.js socket server script, as a service.
This is to make it so that i don’t have to physically run ‘node server.js’ in SSH and have to sit there with it open.
Any help would be appreciated.
Thanks Scott
I don’t see anything criminal in wanting to use something different except
forever. In my project i also avoid using this kind of tools and more rely on system capabilities. Since i also try to avoid running my application as root, i cannot use SystemV nor Upstart.And here comes mighty
shell scripting! I have created fewbashscripts that are doing simply tasks, such asprocess watchdogwith ability to start, stop, restart and query status.Check this code. Feel free to modify it as you will. To use it — put your command there in COMMAND parameter. And execute
./path_to_script.sh -start. This will create watchdog process, which will start your node process and watch if it dies or not and if yes, it will restart it. It is far not ideal, so if anyone has something to fix, add, remove here, feel free to comment below.