node.js - 终端 远程连接服务器,终端关闭后,服务器无法运行
黄舟
黄舟 2017-04-17 15:57:02
0
5
476

我配置好服务器,上传node.js的express项目

远程使用iterm连接服务器
ssh root@xxxxxxxx
进入到express项目目录执行
npm start启动项目
终端显示启动 ./bin/www成功

打开外网网址
显示正常网址
但是当我关闭终端或者使用control+C退出的话
重新刷新网页,出现

请问大家是如何处理这个事情的,我远程启动了项目,但是我总不能一直在我这边开着这个终端吧

黄舟
黄舟

人生最曼妙的风景,竟是内心的淡定与从容!

reply all(5)
迷茫

nohup command &
或者
tmux
Simply put, your program process is a child process of ssh, so when the parent process exits, the child process will also exit.

巴扎黑

Recommended to usepm2或者forever

巴扎黑

Understand the principles of SIGHUP and learn to use one or more of nuhup/screen/tmux/service management (initd or systemd)

Ty80

When the terminal is closed, all processes belonging to it end. You can use pm2, or simply add &(with space)

at the end
PHPzhong

Express has an advanced chapter, the address is here http://expressjs.com/zh-cn/ad..., you can use the process manager to close the terminal server and the nodejs project is still running, you can check it out

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template