.
This commit is contained in:
parent
1a15888de0
commit
0a6b7a822a
37
ecosystem.config.js
Normal file
37
ecosystem.config.js
Normal file
@ -0,0 +1,37 @@
|
||||
const logDateFormat = 'YYYY-MM-DD HH:mm:ss';
|
||||
|
||||
const argv = process.argv;
|
||||
const apps = [];
|
||||
|
||||
const init = (name, id = 0, instances = 1) => {
|
||||
if (!name) throw 'process name is required';
|
||||
|
||||
const defaults = {
|
||||
// args: [name, id],
|
||||
log_date_format: logDateFormat,
|
||||
min_uptime: '60s',
|
||||
max_restarts: 2,
|
||||
name: `tools_${name}`
|
||||
};
|
||||
|
||||
const opt = {};
|
||||
if (name !== 'cron') {
|
||||
Object.assign(opt, {
|
||||
exec_mode: 'cluster', // 进程模式,可选值:cluster/fork
|
||||
instances, // 启动的进程实例数,如果值 5 ,则会启动一个进程数为 5 的进程集群,等效 `pm2 start app -i 5`
|
||||
merge_logs: true // 集群模式,是否合并一个集群的进程日志
|
||||
})
|
||||
}
|
||||
|
||||
apps.push({
|
||||
...defaults,
|
||||
script: `dist/${name}.js`,
|
||||
...opt
|
||||
});
|
||||
};
|
||||
|
||||
init(argv[5], argv[6], argv[7]);
|
||||
|
||||
module.exports = {
|
||||
apps
|
||||
};
|
Loading…
Reference in New Issue
Block a user