comment-questionHow 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

1

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 &
2

You can check for execution with the command below.

 $ ps -aux | grep "npm run start"
3

The output and error logs will be saved to app.log. You can check the log with the command below.

$ cat app.log

How 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.

1

Install forever

$ npm install -g forever
2

Run the app with the command below

$ forever start app.js
3

You can verify whether it's running or not with the command below.

$ forever list
circle-info

For detailed usage, please refer to forever usage.

An 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.

1

Install pm2

2

Run the app with the command below

3

You can verify whether it's running or not with the command below.

Last updated