具有pm2的nodejs使用进程模式

时间:2015-09-05 20:53:28

标签: node.js pm2

我找不到pm2 github文档,如何使用--harmony和process arg的用法?

node --harmony app.js staging

pm2 start app.js --node-args="--harmony-generators"  ??

1 个答案:

答案 0 :(得分:0)

声明JSON配置processes.json:

{
  "apps" : [{
    // Application #1
    "name"        : "worker-app",
    "script"      : "worker.js",
    "args"        : ["--toto=heya coco", "-d", "1"],
    "watch"       : true,
    "node_args"   : "--harmony",
    "merge_logs"  : true,
    "cwd"         : "/this/is/a/path/to/start/script",
    "env": {
        "NODE_ENV": "production",
        "AWESOME_SERVICE_API_TOKEN": "xxx"
    }
  },{
    // Application #2
    "name"       : "api-app",
    "script"     : "api.js",
    "instances"  : 4,
    "exec_mode"  : "cluster_mode",
    "error_file" : "./examples/child-err.log",
    "out_file"   : "./examples/child-out.log",
    "pid_file"   : "./examples/child.pid"
  }]
}

然后你可以运行:

$ pm2 start processes.json