lisk-framework
Version:
Lisk blockchain application platform
52 lines • 1.52 kB
JavaScript
Object.defineProperty(exports, "__esModule", { value: true });
const fs = require("fs");
const engine_1 = require("./engine");
const abi_client_1 = require("./abi_handler/abi_client");
const logger_1 = require("./logger");
const socketPath = process.argv[2];
const configIndex = process.argv.findIndex(arg => arg === '--config' || arg === '-c');
if (configIndex < 0) {
throw new Error(`Engine config is required. config must be specified with --config or -c.`);
}
const configPath = process.argv[configIndex + 1];
if (!configPath) {
throw new Error('Config path is required.');
}
const config = JSON.parse(fs.readFileSync(configPath, 'utf-8'));
const abiLogger = (0, logger_1.createLogger)({
logLevel: config.system.logLevel,
name: 'ABIClient',
});
let started = false;
const client = new abi_client_1.ABIClient(abiLogger, socketPath);
const engine = new engine_1.Engine(client, config);
client
.start()
.then(async () => {
await engine.start();
started = true;
})
.catch(err => {
abiLogger.error({ err: err }, 'Fail to start engine');
process.exit(1);
});
process.on('disconnect', () => {
if (!started) {
return;
}
engine
.stop()
.then(() => {
client.stop();
})
.catch(err => {
abiLogger.error({ err: err }, 'Error occured while stopping the engine');
process.exit(1);
});
});
process.once('SIGINT', () => {
});
process.once('SIGTERM', () => {
});
//# sourceMappingURL=engine_igniter.js.map
;