2019-01-18 16:34:11 -08:00
|
|
|
import * as Sentry from "@sentry/node";
|
2019-01-08 14:58:32 -08:00
|
|
|
import * as Webhooks from "./webhooks";
|
2018-12-28 15:24:46 -08:00
|
|
|
import * as RestServer from "./server";
|
2019-01-18 16:34:11 -08:00
|
|
|
import { initNode } from "./node";
|
2019-03-19 12:56:58 -07:00
|
|
|
import { initBitGo } from "./bitgo";
|
|
|
|
import { extractErrMessage } from "./util";
|
2019-01-18 16:34:11 -08:00
|
|
|
import env from "./env";
|
|
|
|
import log from "./log";
|
2018-12-28 15:24:46 -08:00
|
|
|
|
|
|
|
async function start() {
|
2019-01-18 16:34:11 -08:00
|
|
|
if (env.SENTRY_DSN) {
|
|
|
|
Sentry.init({
|
|
|
|
dsn: env.SENTRY_DSN,
|
|
|
|
environment: env.NODE_ENV,
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
log.info("============== Starting services ==============");
|
2018-12-28 15:24:46 -08:00
|
|
|
await initNode();
|
2019-03-19 12:56:58 -07:00
|
|
|
await initBitGo();
|
2018-12-28 15:24:46 -08:00
|
|
|
await RestServer.start();
|
2019-03-14 20:21:28 -07:00
|
|
|
Webhooks.start();
|
2019-01-18 16:34:11 -08:00
|
|
|
log.info("===============================================");
|
2018-12-28 15:24:46 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
process.on("SIGINT", () => {
|
2019-01-18 16:34:11 -08:00
|
|
|
log.info('Shutting down services...');
|
2019-01-08 14:58:32 -08:00
|
|
|
Webhooks.exit();
|
|
|
|
RestServer.exit();
|
2019-01-18 16:34:11 -08:00
|
|
|
log.info('Exiting!');
|
2018-12-28 15:24:46 -08:00
|
|
|
process.exit();
|
|
|
|
});
|
|
|
|
|
2019-03-19 12:56:58 -07:00
|
|
|
start().catch(err => {
|
|
|
|
Sentry.captureException(err);
|
|
|
|
log.error(`Unexpected error while starting blockchain watcher: ${extractErrMessage(err)}`);
|
|
|
|
process.exit(1);
|
|
|
|
});
|