[英]Do I need to manually restart my app on EC2 if the server restarts?
This is my first time with EC2 so keep that in mind. 这是我第一次使用EC2,因此请记住这一点。 I spun an EC2 instance and put a really basic nodejs/express app up on it.
我旋转了一个EC2实例,并在其上放置了一个非常基本的nodejs / express应用程序。 I connected to the ec2 server via the terminal on my personal computer and ran node app.js to start the app and everything is running fine.
我通过个人计算机上的终端连接到ec2服务器,并运行节点app.js来启动应用程序,并且一切运行正常。 The part I am confused about is how long this will run for.
我感到困惑的部分是它将持续多长时间。 Ideally, I just want it to sit there and not touch it and have it run for hopefully years.
理想情况下,我只希望它坐在那里而不碰它,并让它运行多年。 Will it do this?
会这样做吗? If not what do I need to do?
如果没有,我该怎么办? What if the server restarts for some reason?
如果服务器由于某种原因重新启动怎么办? What is the common practice here?
这里的惯例是什么?
Go to root directory of your project and type this command to run the server permanently. 转到项目的根目录,然后键入此命令以永久运行服务器。
sudo npm install forever -g
forever start -c "node app.js" ./
该博客对于为生产环境设置节点可能会有所帮助
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.