node.js - nodejs 如何在centos下后台运行,nohup和forever都不行呀
天蓬老师
天蓬老师 2017-04-17 16:07:51
0
4
721

我的项目用express框架,需要在centos下后台运行,我百度说有两种方法,nohup和forever,我两种都试过,无效,什么原因?

nohup npm start &

命令结果如下:

浏览器不能访问;

npm install -g forever && forever start app.js

结果如下:

浏览器还是不能访问,求大神解答

天蓬老师
天蓬老师

欢迎选择我的课程,让我们一起见证您的进步~~

reply all(4)
左手右手慢动作

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:显示实时 log
pm2 restart [id]:重启应用
pm2 stop [id]:停止应用
pm2 kill [id]

You can use the PM2 command to start the application directly, or use process.json: 🎜 rrreee 🎜Then use pm2 start process.json to start🎜 🎜Several common commands: 🎜 🎜pm2 list: Display all applications
pm2 monit: Display application monitoring panel
pm2 logs: Display real-time log
pm2 restart [id]: Restart the application
pm2 stop [id]: Stop the application
pm2 kill [id]: Close Application 🎜
黄舟

This express advanced article introduces pm2 and StrongLoop Process Manager. I use StrongLoop Process Manager here, but it comes with a lot of things

洪涛

Provide an article for reference only. Use centos6 to build a nodejs server and set up a blog

Ty80

Yes, use pm2

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