-
Notifications
You must be signed in to change notification settings - Fork 0
/
fireup.js
executable file
·49 lines (43 loc) · 1.15 KB
/
fireup.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
#!/usr/bin/env node
'use strict'
var fs = require('fs');
var Process = require('./lib/process');
var path = require('path');
var chalk = require('chalk');
var debug = require('debug')('fireup');
var utils = require('./lib/utils');
var load = require('./lib/doc').load;
function printUsage() {
var banner = fs.readFileSync(path.join(__dirname, 'banner.txt'));
console.log(chalk.red(banner));
console.log('Simple process launcher for local development');
console.log('Put fireup.yml in current directory or pass it as a parameter');
console.log('See %s for details', path.join(__dirname, 'README.md'));
console.log(require('./package.json').homepage);
}
function main() {
var file = process.argv[2];
if (!file && !utils.exists('fireup.yml')) {
printUsage();
process.exit(1);
}
var doc = load(file);
var ps = {}
for (var p in doc.processes) {
ps[p] = new Process(doc, p);
ps[p].start();
}
process.on('SIGINT', function () {
debug('User interrupt, killing all processes');
for (p in ps) {
ps[p].kill('SIGINT');
}
});
}
try {
main();
} catch (err) {
console.error(err.message);
debug(err);
process.exit(1);
}