PM2启动配置文件参数比较全的一个。如下:{
"name" : "node-app",
"cwd" : "/srv/node-app/current",
"args" : ["--toto=heya coco", "-d", "1"],
"script" : "bin/app.js",
"node_args" : ["--harmony", " --max-stack-size=102400000"],
"log_date_format" : "YYYY-MM-DD HH:mm Z",
"error_file" : "/var/log/node-app/node-app.stderr.log",
"out_file" : "log/node-app.stdout.log",
"pid_file" : "pids/node-geo-api.pid",
"instances" : 6, //or 0 => 'max'
"min_uptime" : "200s", // 200 seconds, defaults to 1000
"max_restarts" : 10, // defaults to 15
"max_memory_restart": "1M", // 1 megabytes, e.g.: "2G", "10M", "100K", 1024 the default unit is byte.
"cron_restart" : "1 0 * * *",
"watch" : false,
"ignore_watch" : ["[\\/\\\\]\\./", "node_modules"],
"merge_logs" : true,
"exec_interpreter" : "node",
"exec_mode" : "fork",
"autorestart" : false, // enable/disable automatic restart when an app crashes or exits
"vizion" : false, // enable/disable vizion features (versioning control)
// Default environment variables that will be injected in any environment and at any start
"env": {
"NODE_ENV": "production",
"AWESOME_SERVICE_API_TOKEN": "xxx"
}
"env_*" : {
"SPECIFIC_ENV" : true
}
}比较有用的参数:cron_restart:定时启动,解决重启能解决的问题max_memory_restart:解决内容不够用的问题,不过会有风险【数据丢失】