I have a express API i need to start this process in background to continue when i close the connection (Ubuntu Server - Terminal)
node --inspect -r ts-node/register server.ts
Thanks
In regards to NodeJS applications, check out PM2
to run, and automatically restart your application in the event of a crash or system reboot .
npm install -g pm2
pm2 start server.js
pm2 save
pm2 startup
Generally in production, you should be utilizing your transpiled JavaScript, instead of TypeScript directly, hence my use of server.js
, but nothing stops you from integrating TypeScript with PM2 .
For a more broad answer, screen
can be used to run processes in the background. This should be installed by default, if not run: sudo apt install screen
Using screen:
screen -S <session_name>
to open a new session, press SPACE
to push through the licensing gibberish.CTRL
A
then CTRL
D
to detach from the session; this will continue to run even if you close your terminal.screen -r <session_name>
to return to your screen session, screen -list
lists all active screen sessions.CTRL
D
or run exit
in a screen session to terminate it.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.