简体   繁体   English

如何在不打开计算机的情况下“永远”托管我的 NodeJS 应用程序?

[英]How can I host my NodeJS app “forever” without my computer being on?

On my website, I host an express app that hosts a different port than what is hosted by Namecheap, which is what I am using for hosting.在我的网站上,我托管了一个 Express 应用程序,该应用程序托管的端口与 Namecheap 托管的端口不同,这是我用于托管的端口。 Right now I'm just hosting the express app in the terminal in cPanel for testing, but when I release the site this way won't be acceptable.现在我只是在 cPanel 的终端中托管 express 应用程序进行测试,但是当我以这种方式发布网站时,这是不可接受的。

Is there a way I could host my express app without my computer always being on and hosting it manually?有没有一种方法可以托管我的 Express 应用程序,而无需我的计算机始终打开并手动托管它?

Install pm2 as global dependency in your hosting server.在您的托管服务器中安装 pm2 作为全局依赖项。

npm i pm2 -g

After that go to app directory and run.之后转到应用程序目录并运行。

pm2 start app.js --name "name of your app"

It will run your application forever until some error may not occur.它将永远运行您的应用程序,直到可能不会发生某些错误。

您可以构建应用程序的 docker 映像并永远运行 docker 容器,或者使用 pm2 或永远等进程管理器以分离模式运行您的应用程序。

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

相关问题 如何使用自己的主机在nodejs中发送电子邮件? - How can I send email in nodejs using my own host? NodeJS-让我的应用程序永远运行 - NodeJS - Keep my App running with Forever 如何使用服务器域名从本地计算机访问我的nodejs Web服务器? - How can I access my nodejs web server from my local computer using the server domain name? 如何在服务器的控制台中访问我的nodeJS应用程序? - How can I access to my nodeJS app in console on my server? 如何检测到我的Node.js脚本永远被终止? - How can I detect that my Node.js script is being terminated by forever? 即使我使用的是永久性的npm模块,如何使我的web服务在nodejs中保持永久性运行? - How to keep my web services awake in nodejs to run forever though i am using forever npm module? nodejs 永远:如何运行我的 npm 应用程序 - nodejs forever : How to run my npm application 我可以强制永远不要重新启动我的应用程序吗? - Node.js Can I force forever not to restart my app? 如果将我的nodejs应用程序托管在Heroku或其他托管平台上,是否可以忽略使用HTTPS服务我的应用程序? - If I host my nodejs application on Heroku or other hosting platform can I ignore serving my app using HTTPS? 如何将mongodb与Bluemix上的NODEjs应用程序连接? - How can I connect my mongodb with the NODEjs app on Bluemix?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM