forked from odota/core
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdeploy.js
More file actions
39 lines (37 loc) · 770 Bytes
/
deploy.js
File metadata and controls
39 lines (37 loc) · 770 Bytes
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
37
38
39
var pm2 = require('pm2');
var async = require('async');
var config = require('./config');
var args = process.argv.slice(2);
var manifest = require('./package.json');
if (config.ROLE)
{
//if role variable is set just run that script
require('./' + config.ROLE + ".js");
}
else
{
//specific role not set, just use pm2 to run the production config
pm2.connect(function()
{
async.each(manifest.apps, start, exit);
});
}
function exit(err)
{
if (err)
{
console.error(err);
}
pm2.disconnect();
}
function start(app, cb)
{
if (args[0] === app.role || !args[0])
{
console.log(app.script, app.instances);
pm2.start(app.script,
{
instances: app.instances
}, cb);
}
}