简体   繁体   English

如何部署没有root访问权限的NodeJS应用程序,使其在服务器重新启动后保持联机状态?

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

I'm trying to deploy my NodeJS app. 我正在尝试部署我的NodeJS应用程序。 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. 我尝试过永久使用npm和pm2,但是我相信托管人每天晚上都会重新启动服务器,因为第二天我的应用程序始终处于脱机状态。

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... 事实是,我在A2hosting上有一个共享的托管服务器,并且没有root访问权,因此这些sudo命令在这里不起作用...除了您知道我可以如何更改之外,哈哈...

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. 我已经用pm2做到了。

npm install -g pm2

then you run the following command to ensure pm2 will run on startup: 然后运行以下命令以确保pm2将在启动时运行:

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 有关pm2文档的更多详细信息: https : //github.com/Unitech/pm2

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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