How To Leave a NodeJS Process Running[SOLVED]

Hi guys I have a small remote droplet server from digital ocearn hosting a Linux web server and to start the server I have to ssh into the server to turn it on. How do I make it so I can disconnect the SSH and leave the process running?

use tmux. You can open the SSH connection and start tmux on the server and inside tmux you start the application . When you disconnect tmux will keep running in its own session or somthing.

Well I want to be able to turn the computer off.

two things. there's a package in NPM called pm2 which is designed for just this thing.

Also, with tmux, once you get the process in tmux running, you type ctrl+b then d which will detach the tmux session and you will be able to log out of the SSH session.

2 Likes

Did not know about pm2

For a more robust system wide approach you could make a systemd service for it https://www.axllent.org/docs/view/nodejs-service-with-systemd/

1 Like