forked from odota/core
-
Notifications
You must be signed in to change notification settings - Fork 0
/
deploy.js
46 lines (46 loc) · 1.16 KB
/
deploy.js
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
40
41
42
43
44
45
46
/**
* Deployment entry point for the application.
**/
var args = process.argv.slice(2);
var group = args[0] || process.env.GROUP;
var cp = require('child_process');
if (process.env.PROVIDER === "gce")
{
cp.execSync('curl -H "Metadata-Flavor: Google" -L http://metadata.google.internal/computeMetadata/v1/project/attributes/env > /usr/src/yasp/.env');
}
if (process.env.ROLE)
{
//if role variable is set just run that script
require('./svc/' + process.env.ROLE + ".js");
}
else if (group)
{
var pm2 = require('pm2');
var async = require('async');
var manifest = require('./profiles/everything.json').apps;
pm2.connect(function()
{
async.each(manifest, function start(app, cb)
{
if (group === app.group)
{
console.log(app.script, app.instances);
pm2.start(app.script,
{
instances: app.instances
}, cb);
}
}, function exit(err)
{
if (err)
{
console.error(err);
}
pm2.disconnect();
});
});
}
else
{
process.stdin.resume();
}