-
Notifications
You must be signed in to change notification settings - Fork 0
/
cli.js
executable file
·51 lines (37 loc) · 1020 Bytes
/
cli.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
47
48
49
50
51
#!/usr/bin/env node
var commander = require('commander');
var pkg = require('./package.json');
var fs = require('fs');
var JSON5 = require('json5');
var process = require('process');
var utils = require('./lib/utils.js');
var eco = utils.eco;
var appDefinition = {
name: "pm2dri_" + utils.projectPkg.name,
script: "./node_modules/.bin/pm2dri",
args: ['run'],
env: {"DEBUG": "info,warn,error"}
}
var run = function(cmd){
// Full log
process.env.DEBUG = 'info,warn,debug';
require('./app.js').restServer();
}
var init = function(cmd){
// Drop old
for(var i=0; i< eco.apps.length; i++){
if(eco.apps[i].name===appDefinition.name){
eco.apps.splice(i, 1);
}
}
eco.apps.push(appDefinition);
fs.writeFileSync(utils.deploymentFile, JSON5.stringify(eco, null, 2));
}
commander.version(pkg.version);
commander.command('init')
.description("Add app to project ecosystem file")
.action(init);
commander.command('run')
.description("Starts service")
.action(run);
commander.parse(process.argv);