2014-07-25 03:11:23 +04:00
|
|
|
#!/usr/bin/env node
|
|
|
|
|
|
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
|
|
|
|
|
|
|
const cp = require('child_process');
|
|
|
|
const path = require('path');
|
|
|
|
|
2014-08-14 20:27:23 +04:00
|
|
|
const mkdirp = require('mkdirp');
|
|
|
|
const rimraf = require('rimraf');
|
|
|
|
|
2017-01-10 23:16:21 +03:00
|
|
|
process.env.NODE_ENV = 'development';
|
2014-07-25 03:11:23 +04:00
|
|
|
|
2016-07-21 21:58:16 +03:00
|
|
|
var childServer = cp.fork(path.join(__dirname, '..', 'bin', 'server.js'));
|
|
|
|
childServer.on('exit', process.exit);
|
2014-07-25 03:11:23 +04:00
|
|
|
|
2016-07-21 21:58:16 +03:00
|
|
|
var childWorker = cp.fork(path.join(__dirname, '..', 'bin', 'worker.js'));
|
|
|
|
childWorker.on('exit', process.exit);
|
2014-08-14 20:27:23 +04:00
|
|
|
|
2014-07-25 03:11:23 +04:00
|
|
|
|
2014-08-14 20:27:23 +04:00
|
|
|
mkdirp.sync(path.join(__dirname, '..', 'var', 'public'));
|
2016-07-21 21:58:16 +03:00
|
|
|
var childStatic = cp.fork(path.join(__dirname, '..', 'bin', '_static.js'));
|
|
|
|
childStatic.on('exit', process.exit);
|
2014-08-14 20:27:23 +04:00
|
|
|
|
|
|
|
process.on('exit', function() {
|
2016-07-21 21:58:16 +03:00
|
|
|
try {
|
|
|
|
// if one of the child processes crashes or exits then we stop everything else.
|
|
|
|
childServer.kill();
|
|
|
|
childWorker.kill();
|
|
|
|
childStatic.kill();
|
|
|
|
} catch (e) {
|
|
|
|
console.log(e); // eslint-disable-line no-console
|
|
|
|
}
|
2014-08-14 20:27:23 +04:00
|
|
|
rimraf.sync(path.join(__dirname, '..', 'var', 'public'));
|
|
|
|
});
|