How to run as background process
If you turn off the Auto-stop feature, the container will remain running even if you close the Workspace, but processes running in the terminal will be terminated. To prevent this, you need to run the process as a background process using the nohup command.
Use nohup command
How to run
For example, to run npm run start command in the background, you can use the setsid nohup command together as shown below.
$ setsid nohup npm run start > app.log 2>&1 &You can check for execution with the command below.
$ ps -aux | grep "npm run start"The output and error logs will be saved to app.log. You can check the log with the command below.
$ cat app.logHow to end
After finding the PID value with the ps command, end the process with the kill command.
$ ps -ef | grep "npm run start"
[1] [Your PID]
$ kill -TERM [Your PID]If you are using node app
You can simply run it as a background process using the forever command in the npm package.
Install forever
$ npm install -g foreverRun the app with the command below
$ forever start app.jsYou can verify whether it's running or not with the command below.
$ forever listAn app that uses npm start
You can run the command set in scripts.start of package.json using npm start, but with PM2, you can run it more easily as a background application.
Install pm2
Run the app with the command below
You can verify whether it's running or not with the command below.
Last updated