简体   繁体   中英

How to deploy a NodeJS app without root access, so it stays online after server restarts?

I'm trying to deploy my NodeJS app. I tried npm forever and pm2, but I believe that my hoster restarts the server every night because my app is always offline the next day.

The thing is, that I have a shared hosting server on A2hosting and don't have root access, so these sudo commands don't work here... except you know how I can change that, haha...

I don't know what infos I need to provide for you to help me... so if you need to know something, tell me please!

Thank you so much!

I've used pm2 to do that.

npm install -g pm2

then you run the following command to ensure pm2 will run on startup:

pm2 startup

It will show you the command you have to run.

Finally, you initiate the process:

pm2 start server.js --name <service-name>

Freeze your process list:

pm2 save

More details on pm2 documentation: https://github.com/Unitech/pm2

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM