-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathJakefile.js
More file actions
200 lines (153 loc) · 5.26 KB
/
Jakefile.js
File metadata and controls
200 lines (153 loc) · 5.26 KB
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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
var fs = require('fs'),
path = require('path'),
spawn = require('child_process').spawn,
passthru = require('passthru');
var componentsBaseDir = './components';
var components = ['muchmala-app', 'muchmala-frontend',
'muchmala-generator', 'muchmala-lb'];
desc('Install everything');
task('install',
['install-components'],
function() {});
desc('Install all components');
task('install-components',
['install-muchmala-common',
'install-muchmala-app', 'install-muchmala-frontend',
'install-muchmala-generator', 'install-muchmala-lb',
'install-muchmala-scripts'],
function() {});
desc('Install muchmala-common');
task('install-muchmala-common', function() {
console.log('Installing muchmala-common...');
var cwd = componentsBaseDir + '/muchmala-common';
// we're doing it in two steps to overcome virtualbox permissions bugs
passthru('npm install', {cwd: cwd}, failOnError(function() {
passthru('sudo -E npm link', {cwd: cwd}, failOnError(function() {
complete();
}));
}));
}, true);
desc('Install muchmala-app');
task('install-muchmala-app', function() {
console.log('Installing muchmala-app...');
componentNpmInstall('muchmala-app', failOnError(function() {
complete();
}));
}, true);
desc('Install muchmala-frontend');
task('install-muchmala-frontend', function() {
console.log('Installing muchmala-frontend...');
componentNpmInstall('muchmala-frontend', failOnError(function() {
complete();
}));
}, true);
desc('Install muchmala-generator');
task('install-muchmala-generator', function() {
console.log('Installing muchmala-generator...');
componentNpmInstall('muchmala-generator', failOnError(function() {
complete();
}));
}, true);
desc('Install muchmala-lb');
task('install-muchmala-lb', function() {
console.log('Installing muchmala-lb...');
componentNpmInstall('muchmala-lb', failOnError(function() {
complete();
}));
}, true);
desc('Install muchmala-scripts');
task('install-muchmala-scripts', function() {
console.log('Installing muchmala-scripts...');
componentNpmInstall('muchmala-scripts', failOnError(function() {
complete();
}));
}, true);
desc('Start all services');
task('start', ['start-muchmala-lb', 'start-muchmala-frontend'], function() {
passthru('sudo -E supervisorctl start muchmala:', failOnError(function() {
complete();
}));
}, true);
desc('Stop all services');
task('stop', ['stop-muchmala-lb', 'stop-muchmala-frontend'], function() {
passthru('sudo -E supervisorctl stop muchmala:', failOnError(function() {
complete();
}));
}, true);
desc('Restart all services');
task('restart', ['restart-muchmala-lb', 'restart-muchmala-frontend'], function() {
passthru('sudo -E supervisorctl restart muchmala:', failOnError(function() {
complete();
}));
}, true);
desc('Start muchmala-lb');
task('start-muchmala-lb', function() {
console.log('Starting muchmala-lb...');
var cwd = componentsBaseDir + '/muchmala-lb';
passthru('sudo -E bin/muchmala-lb.sh', {cwd: cwd}, failOnError(function() {
complete();
}));
}, true);
desc('Stop muchmala-lb');
task('stop-muchmala-lb', function() {
console.log('Stopping muchmala-lb...');
var cwd = componentsBaseDir + '/muchmala-lb';
passthru('sudo -E bin/muchmala-lb.sh stop', {cwd: cwd}, failOnError(function() {
complete();
}));
}, true);
desc('Restart muchmala-lb');
task('restart-muchmala-lb', function() {
console.log('Restarting muchmala-lb...');
var cwd = componentsBaseDir + '/muchmala-lb';
passthru('sudo -E bin/muchmala-lb.sh restart', {cwd: cwd}, failOnError(function() {
complete();
}));
}, true);
desc('Start muchmala-frontend');
task('start-muchmala-frontend', function() {
console.log('Starting muchmala-frontend...');
var cwd = componentsBaseDir + '/muchmala-frontend';
passthru('sudo -E bin/muchmala-frontend.sh', {cwd: cwd}, failOnError(function() {
complete();
}));
}, true);
desc('Stop muchmala-frontend');
task('stop-muchmala-frontend', function() {
console.log('Stopping muchmala-frontend...');
var cwd = componentsBaseDir + '/muchmala-frontend';
passthru('sudo -E bin/muchmala-frontend.sh stop', {cwd: cwd}, failOnError(function() {
complete();
}));
}, true);
desc('Restart muchmala-frontend');
task('restart-muchmala-frontend', function() {
console.log('Restarting muchmala-frontend...');
var cwd = componentsBaseDir + '/muchmala-frontend';
passthru('sudo -E bin/muchmala-frontend.sh restart', {cwd: cwd}, failOnError(function() {
complete();
}));
}, true);
function failOnError(callback) {
return function(err) {
if (err) {
fail(err);
return;
}
callback.apply(null, Array.prototype.slice.call(arguments));
}
}
function componentNpmInstall(component, callback) {
var cwd = componentsBaseDir + '/' + component;
passthru('npm link muchmala-common', {cwd: cwd}, function(err) {
if (err) {
return callback(err);
}
passthru('npm install', {cwd: cwd}, function(err) {
if (err) {
return callback(err);
}
callback();
})
});
}