-
Notifications
You must be signed in to change notification settings - Fork 419
/
startup
36 lines (32 loc) · 1018 Bytes
/
startup
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
#!/usr/bin/env node
var pm2 = require('pm2'),
config = require('./config'),
util = require('util');
pm2.connect(function (err) {
if (err) {
console.error(err);
process.exit(0);
}
var method = process.argv.slice(2)[0],
port = process.argv.slice(2)[1];
if (!method || !port) {
console.error('请输入方法名和端口号,例如: \n\tnode startup worker 3000\n\tnode startup male 1');
process.exit(0);
} else {
pm2.start('src/queen.js', {
name: util.format('%s[%s]', method, port),
maxMemoryRestart: config.memoryLimit,
nodeArgs: ['--max-old-space-size=' + config.memoryLimit[method]],
scriptArgs: [method, port],
force: true
}, function (err, proc) {
if (err) {
console.error(err);
process.exit(0);
}
pm2.disconnect(function () {
process.exit(0);
});
});
}
});