2019-01-30 15:47:03 +00:00
|
|
|
#!/usr/bin/env node
|
2019-01-27 14:54:29 +00:00
|
|
|
|
2019-01-30 15:47:03 +00:00
|
|
|
var program = require('commander');
|
|
|
|
var execSync = require('child_process').execSync;
|
|
|
|
var spawn = require('child_process').spawn;
|
2019-01-30 22:33:14 +00:00
|
|
|
var fs = require('fs');
|
2019-01-30 15:47:03 +00:00
|
|
|
|
|
|
|
program
|
|
|
|
.option('-c, --config <config>', 'Configuration file to run Authelia with.')
|
|
|
|
.option('--no-watch', 'Disable hot reload.')
|
|
|
|
.parse(process.argv);
|
2019-01-27 14:54:29 +00:00
|
|
|
|
2019-01-30 15:47:03 +00:00
|
|
|
let config = 'config.yml'; // set default config file.
|
2019-01-27 14:54:29 +00:00
|
|
|
|
2019-01-30 15:47:03 +00: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]);
|
|
|
|
}
|
|
|
|
|
2019-01-30 22:33:14 +00:00
|
|
|
var logStream = fs.createWriteStream('/tmp/authelia-server.log', {flags: 'a'});
|
|
|
|
|
2019-01-30 15:47:03 +00:00
|
|
|
server.stdout.on('data', (data) => {
|
|
|
|
process.stdout.write(`${data}`);
|
|
|
|
});
|
2019-01-30 22:33:14 +00:00
|
|
|
server.stdout.pipe(logStream);
|
2019-01-30 15:47:03 +00:00
|
|
|
|
|
|
|
server.stderr.on('data', (data) => {
|
|
|
|
process.stderr.write(`${data}`);
|
|
|
|
});
|
2019-01-30 22:33:14 +00:00
|
|
|
server.stderr.pipe(logStream);
|
2019-02-24 15:42:29 +00:00
|
|
|
|
|
|
|
|
|
|
|
server.on('exit', function(statusCode) {
|
|
|
|
process.exit(statusCode);
|
|
|
|
})
|