How to run multiple app using PM2?

前端 未结 4 854
北荒
北荒 2021-01-21 07:02

I want to run my angular4 app using PM2 it will run but when I am close the terminal it will stop.

  1. On this server already run

4条回答
  •  一生所求
    2021-01-21 07:43

    If you are using PM2 properly, your applications should not be turning off after terminal exit. It is very likely that your application is failing. Run pm2 logs to diagnose.

    You can specify multiple applications in a process.json file like this:

    {
        "apps" : [{
            "name"        : "worker",
            "script"      : "./worker.js",
            "watch"       : true,
            "env": {
                "NODE_ENV": "development"
            },
            "env_production" : {
                "NODE_ENV": "production"
            }
        },{
            "name"       : "api-app",
            "script"     : "./api.js",
            "instances"  : 4,
            "exec_mode"  : "cluster"
        }]
    }
    

    Documentation Here

    Started like this:

    pm2 start process.json
    

    And can monitor/view your applications by running pm2 monit or pm2 ls

提交回复
热议问题