Make db location configurable #1177

Make db location configurable #1177
This commit is contained in:
ShahanaFarooqui 2023-02-17 17:33:33 -08:00
parent ceceab04af
commit 8e65dd2c9e
17 changed files with 57 additions and 42 deletions

11
rtl.js
View file

@ -1,8 +1,9 @@
import http from 'http';
import App from './backend/utils/app.js';
import { Logger } from './backend/utils/logger.js';
import { Common } from './backend/utils/common.js';
import { Config } from './backend/utils/config.js'; // Follow sequence to set server configuration in time
import { WSServer } from './backend/utils/webSocketServer.js';
import App from './backend/utils/app.js';
const logger = Logger;
const common = Common;
@ -13,11 +14,11 @@ const onError = (error) => {
if (error.syscall !== 'listen') { throw error; }
switch (error.code) {
case 'EACCES':
logger.log({ level: 'ERROR', fileName: 'RTL', msg: 'http://' + (common.host ? common.host : 'localhost') + ':' + common.port + ' requires elevated privileges' });
logger.log({ level: 'ERROR', fileName: 'RTL', msg: 'http://' + ((common.host && common.host !== '') ? common.host : 'localhost') + ':' + common.port + ' requires elevated privileges' });
process.exit(1);
break;
case 'EADDRINUSE':
logger.log({ level: 'ERROR', fileName: 'RTL', msg: 'http://' + (common.host ? common.host : 'localhost') + ':' + common.port + ' is already in use' });
logger.log({ level: 'ERROR', fileName: 'RTL', msg: 'http://' + ((common.host && common.host !== '') ? common.host : 'localhost') + ':' + common.port + ' is already in use' });
process.exit(1);
break;
case 'ECONNREFUSED':
@ -35,7 +36,7 @@ const onError = (error) => {
};
const onListening = () => {
logger.log({ level: 'INFO', fileName: 'RTL', msg: 'Server is up and running, please open the UI at http://' + (common.host ? common.host : 'localhost') + ':' + common.port + ' or your proxy configured url' });
logger.log({ level: 'INFO', fileName: 'RTL', msg: 'Server is up and running, please open the UI at http://' + ((common.host && common.host !== '') ? common.host : 'localhost') + ':' + common.port + ' or your proxy configured url' });
};
let server = http.createServer(app.getApp());
@ -45,7 +46,7 @@ server.on('listening', onListening);
wsServer.mount(server);
if (common.host) {
if (common.host && common.host !== '') {
server.listen(common.port, common.host);
} else {
server.listen(common.port);