2016-11-23 01:03:33 +02:00
|
|
|
const cp = require('child_process');
|
2016-11-23 18:27:02 +02:00
|
|
|
const path = require('path');
|
2016-11-23 01:03:33 +02:00
|
|
|
|
|
|
|
const TYPE = process.env.TYPE;
|
|
|
|
const MODE = process.env.MODE;
|
|
|
|
|
|
|
|
if (!TYPE) {
|
|
|
|
console.error(`
|
|
|
|
Usage: TYPE={type} node start.js
|
|
|
|
TYPE=node node start.js
|
|
|
|
`.trim());
|
|
|
|
|
|
|
|
process.exit(1);
|
|
|
|
}
|
|
|
|
|
|
|
|
const handler = ({
|
|
|
|
node: () => {
|
2016-11-25 03:37:38 +02:00
|
|
|
const root = path.join(__dirname, '../');
|
|
|
|
const script = path.join(root, 'src/server/index.js');
|
|
|
|
return cp.exec(`node ${script}`, {
|
2016-11-23 01:03:33 +02:00
|
|
|
cwd: __dirname
|
2016-11-25 03:37:38 +02:00
|
|
|
});
|
2016-11-23 01:03:33 +02:00
|
|
|
},
|
|
|
|
artillery: () => {
|
2016-11-23 18:27:02 +02:00
|
|
|
const conf = path.join(__dirname, '../artillery/artillery-${MODE}.yml');
|
2016-11-25 12:31:38 +02:00
|
|
|
const bin = path.join(__dirname, '../node_modules/.bin/artillery');
|
|
|
|
return cp.exec(`${bin} run ${conf}`);
|
2016-11-23 01:03:33 +02:00
|
|
|
}
|
|
|
|
})[TYPE];
|
|
|
|
|
|
|
|
if (!handler) {
|
|
|
|
console.error(`No handler for ${TYPE}`);
|
|
|
|
process.exit(1);
|
|
|
|
}
|
|
|
|
|
|
|
|
handler().stdout.pipe(process.stdout);
|
|
|
|
handler().stderr.pipe(process.stderr);
|
|
|
|
process.stdin.pipe(handler().stdin);
|