-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy path_start.js
40 lines (33 loc) · 1.2 KB
/
_start.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
'use strict';
var BB = require('bluebird'),
execSync = require('child_process').execSync,
running = false,
grasshopper;
module.exports = start;
function start() {
return BB
.resolve()
.then(function() {
process.stdout.write(execSync('grunt data:load'));
})
.then(function() {
return new BB(function(resolve, reject) {
// TODO: create way of stopping gh - or having inti call system/db start again
if (running) {
resolve(grasshopper);
} else {
grasshopper = require('../lib/grasshopper').init(require('./fixtures/config'));
grasshopper.event.channel('/system/*').on('error', function(payload, next){
console.log('grasshopper error:', payload);
next();
reject();
});
grasshopper.event.channel('/system/db').on('start', function(payload, next) {
running = true;
next();
resolve(grasshopper);
});
}
})
});
}