search

Home  >  Q&A  >  body text

node.js - nodejs 如何在centos下后台运行,nohup和forever都不行呀

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

nohup npm start &

命令结果如下:

浏览器不能访问;

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

结果如下:

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

天蓬老师天蓬老师2785 days ago709

reply all(4)I'll reply

  • ringa_lee

    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:显示实时 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 🎜

    reply
    0
  • 黄舟

    黄舟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

    reply
    0
  • PHP中文网

    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

    reply
    0
  • PHP中文网

    PHP中文网2017-04-17 16:09:51

    Yes, use pm2

    reply
    0
  • Cancelreply