2020-08-24 00:00:26 +00:00
|
|
|
#!/usr/bin/env node
|
|
|
|
|
|
|
|
const syncloungeSocket = require('syncloungesocket');
|
2020-09-16 04:52:11 +00:00
|
|
|
const path = require('path');
|
2020-08-24 00:00:26 +00:00
|
|
|
const config = require('./config');
|
|
|
|
|
|
|
|
// Using a single function to handle multiple signals
|
|
|
|
const handle = (signal) => {
|
|
|
|
console.log(`Received ${signal}. Exiting`);
|
|
|
|
process.exit(0);
|
|
|
|
};
|
|
|
|
|
|
|
|
process.on('SIGINT', handle);
|
|
|
|
process.on('SIGTERM', handle);
|
|
|
|
|
|
|
|
const blockList = Object.keys(syncloungeSocket.defaultConfig);
|
2020-08-31 22:55:14 +00:00
|
|
|
const appConfig = config.get(null, blockList);
|
2020-08-24 00:00:26 +00:00
|
|
|
console.log(appConfig);
|
|
|
|
|
2020-09-11 02:44:33 +00:00
|
|
|
const preStaticInjection = (router) => {
|
|
|
|
// Add route for config
|
|
|
|
router.get('/config.json', (req, res) => {
|
|
|
|
res.json(appConfig);
|
|
|
|
});
|
|
|
|
};
|
|
|
|
|
2020-08-24 00:00:26 +00:00
|
|
|
const socketConfig = syncloungeSocket.getConfig();
|
2020-09-11 02:44:33 +00:00
|
|
|
syncloungeSocket.socketServer({
|
2020-08-24 01:08:44 +00:00
|
|
|
...socketConfig,
|
2020-09-16 04:52:11 +00:00
|
|
|
static_path: path.join(__dirname, 'dist'),
|
2020-09-11 02:44:33 +00:00
|
|
|
preStaticInjection,
|
2020-08-31 22:55:14 +00:00
|
|
|
});
|