Start nodejs app on linux server with ssh(if i close the ssh connection,app stopped why?) 1-create nodejs app -its oke 2-run on linux server -its oke(i stop the apache server) But if i close the ssh connection(with my windows pc),app stopped.How can i solve this problem?
Advertisement
Answer
The most correct thing to do is to write a service file for it so whatever init system you have (likely systemd) will keep it running and manage the start/stop/restart stuff for you.
Failing that (and I don’t blame you…) you can run it within the screen
utility. Launch it with screen -d -m /path/to/start/script
and then you can come back later and reconnect to it with screen -r
or screen -r <pid of the screen session>
.
Note that launching it that way won’t restart it, etc. To do that, you could do something like
#!/bin/sh while true do sleep 3s /path/to/start/script done
And call that with the screen command.