tools/ecosystem.config.js
2023-12-30 12:55:12 +08:00

38 lines
864 B
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

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
};