我的项目用express框架,需要在centos下后台运行,我百度说有两种方法,nohup和forever,我两种都试过,无效,什么原因?
nohup npm start &
命令结果如下:
浏览器不能访问;
npm install -g forever && forever start app.js
结果如下:
浏览器还是不能访问,求大神解答
ringa_lee2017-04-17 16:09:51
Give up Baidu
The most popular tool now is PM2: https://github.com/Unitech/pm2
You can simply install npm install -g pm2
globally, and then start the application with PM2. npm install -g pm2
,然后用 PM2 启动应用即可。
可以使用 PM2 命令直接启动应用,或者使用 process.json
:
{
"name": "your-app",
"script": "inde.js",
"watch": true,
"ignore_watch": ["logs", "assets", "views"],
"env": {
"NODE_ENV": "production",
},
"instances": 1,
"log_date_format": "YYYY-MM-DD hh:mm:ss",
}
然后用 pm2 start process.json
来启动
几个常用命令:
pm2 list
:显示所有应用pm2 monit
:显示应用监控面板pm2 logs
:显示实时 logpm2 restart [id]
:重启应用pm2 stop [id]
:停止应用pm2 kill [id]
process.json
: 🎜
rrreee
🎜Then use pm2 start process.json
to start🎜
🎜Several common commands: 🎜
🎜pm2 list
: Display all applicationspm2 monit
: Display application monitoring panelpm2 logs
: Display real-time logpm2 restart [id]
: Restart the applicationpm2 stop [id]
: Stop the applicationpm2 kill [id]
: Close Application 🎜黄舟2017-04-17 16:09:51
This express advanced article introduces pm2 and StrongLoop Process Manager. I use StrongLoop Process Manager here, but it comes with a lot of things
PHP中文网2017-04-17 16:09:51
Provide an article for reference only. Use centos6 to build a nodejs server and set up a blog