2020-10-05 13:38:03 +02:00
|
|
|
import {delimiter} from "path";
|
|
|
|
|
2020-11-13 10:54:35 +01:00
|
|
|
// Load config from specified path or default + swaf/config (default defaults)
|
2020-09-03 08:28:57 +02:00
|
|
|
process.env['NODE_CONFIG_DIR'] =
|
2021-01-25 13:17:41 +01:00
|
|
|
__dirname + '/../node_modules/swaf/config/'
|
2020-10-05 13:38:03 +02:00
|
|
|
+ delimiter
|
2021-01-25 13:17:41 +01:00
|
|
|
+ (process.env['NODE_CONFIG_DIR'] || __dirname + '/../config/');
|
2020-09-03 08:28:57 +02:00
|
|
|
|
2021-01-25 13:17:41 +01:00
|
|
|
import {logger} from "swaf/Logger";
|
2020-06-27 17:20:06 +02:00
|
|
|
import App from "./App";
|
|
|
|
import config from "config";
|
2021-11-20 19:54:59 +01:00
|
|
|
import {promises as fs} from "fs";
|
2020-04-23 18:07:55 +02:00
|
|
|
|
|
|
|
(async () => {
|
2021-01-25 13:17:41 +01:00
|
|
|
logger.debug('Config path:', process.env['NODE_CONFIG_DIR']);
|
2020-09-03 12:58:07 +02:00
|
|
|
|
2021-11-20 19:54:59 +01:00
|
|
|
const packageJson = JSON.parse((await fs.readFile('package.json')).toString());
|
|
|
|
|
|
|
|
const app = new App(
|
|
|
|
packageJson.version,
|
|
|
|
config.get<string>('app.listen_addr'),
|
|
|
|
config.get<number>('app.port'),
|
|
|
|
);
|
2020-04-23 18:07:55 +02:00
|
|
|
await app.start();
|
|
|
|
})().catch(err => {
|
2021-01-25 13:17:41 +01:00
|
|
|
logger.error(err);
|
2020-10-05 13:38:03 +02:00
|
|
|
});
|