我创建了一个简单的NodeJS应用程序,现在将其移至AWS中的服务器.
I've created a simple NodeJS app which I have now moved up to a server in AWS.
我能够ssh进入服务器并启动应用程序,但是很明显,一旦我关闭终端,该过程就会停止.
I'm able to ssh into the server and start the application but obviously as soon as I close the terminal the process stops.
关闭终端后,如何启动NodeJS应用并使其运行?
How to I start my NodeJS app and keep it running after I've closed my terminal?
推荐答案这不是特定的nodejs问题,尽管有特定的解决方案(例如永远).
That's not a specific nodejs problem, although there are specific solutions (for example forever).
一个通用的解决方案是使用nohup启动它,该解决方案可在Linux上远程启动任何程序,并且在关闭会话时不会死机.这是一个示例,其中我启动节点并将标准输出和错误输出都重定向到server.log文件:
A generic solution to remotely start any program on linux and not have it die when you close the session is to launch it using nohup. Here's an example in which I launch node and redirect both the standard and error outputs into the server.log file :
nohup node main.js >> server.log 2>&1 < /dev/null &更多推荐
如何在远程服务器上启动NodeJS进程?
发布评论