2019-01-30 22:47:03 +07:00
|
|
|
#!/usr/bin/env node
|
2019-01-27 21:54:29 +07:00
|
|
|
|
2019-01-30 22:47:03 +07:00
|
|
|
var program = require('commander');
|
|
|
|
var execSync = require('child_process').execSync;
|
|
|
|
var spawn = require('child_process').spawn;
|
|
|
|
|
|
|
|
program
|
|
|
|
.option('-c, --config <config>', 'Configuration file to run Authelia with.')
|
|
|
|
.option('--no-watch', 'Disable hot reload.')
|
|
|
|
.parse(process.argv);
|
2019-01-27 21:54:29 +07:00
|
|
|
|
2019-01-30 22:47:03 +07:00
|
|
|
let config = 'config.yml'; // set default config file.
|
2019-01-27 21:54:29 +07:00
|
|
|
|
2019-01-30 22:47:03 +07:00
|
|
|
if (program.config) {
|
|
|
|
config = program.config;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Render the production version of the nginx portal configuration
|
|
|
|
execSync('./example/compose/nginx/portal/render.js --production');
|
|
|
|
|
|
|
|
// Prepare the environment
|
|
|
|
execSync('./scripts/utils/prepare-environment.sh');
|
|
|
|
|
|
|
|
var server;
|
|
|
|
if (program.watch) {
|
|
|
|
server = spawn('./node_modules/.bin/nodemon',
|
|
|
|
['-e', 'yml', '--ignore', './users_database*.yml', '--exec', `node dist/server/src/index.js ${config}`]);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
server = spawn('/usr/bin/env', ['node', 'dist/server/src/index.js', config]);
|
|
|
|
}
|
|
|
|
|
|
|
|
server.stdout.on('data', (data) => {
|
|
|
|
process.stdout.write(`${data}`);
|
|
|
|
});
|
|
|
|
|
|
|
|
server.stderr.on('data', (data) => {
|
|
|
|
process.stderr.write(`${data}`);
|
|
|
|
});
|