"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const tslib_1 = require("tslib");
process.env.GEM_MINE_CLI_API_MODE = 'true';
const http = require("http");
const config_1 = require("./config");
const app_1 = require("./app");
const socket_1 = require("./socket");
const db_1 = require("./db");
function start() {
    return tslib_1.__awaiter(this, void 0, void 0, function* () {
        yield db_1.initDB();
        const server = http.createServer(app_1.default.callback());
        socket_1.default(server);
        server.listen(config_1.default.PORT, () => {
            console.log(`Koa Start at ${config_1.default.PORT}`);
            process.send && process.send({
                type: 'cli-service: start success',
                data: {}
            });
            process.on('message', (packet) => {
                if (packet.topic === 'cli-service: check alive') {
                    process.send && process.send({
                        type: 'cli-service: alive',
                        data: {}
                    });
                }
            });
        });
    });
}
start();
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi9zcmMvaW5kZXgudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6Ijs7O0FBQUEsT0FBTyxDQUFDLEdBQUcsQ0FBQyxxQkFBcUIsR0FBRyxNQUFNLENBQUE7QUFFMUMsNkJBQTRCO0FBQzVCLHFDQUE2QjtBQUU3QiwrQkFBdUI7QUFDdkIscUNBQW1DO0FBQ25DLDZCQUE2QjtBQUU3QixTQUFlLEtBQUs7O1FBQ2xCLE1BQU0sV0FBTSxFQUFFLENBQUE7UUFDZCxNQUFNLE1BQU0sR0FBRyxJQUFJLENBQUMsWUFBWSxDQUFDLGFBQUcsQ0FBQyxRQUFRLEVBQUUsQ0FBQyxDQUFBO1FBQ2hELGdCQUFZLENBQUMsTUFBTSxDQUFDLENBQUE7UUFDcEIsTUFBTSxDQUFDLE1BQU0sQ0FBQyxnQkFBTSxDQUFDLElBQUksRUFBRSxHQUFHLEVBQUU7WUFDOUIsT0FBTyxDQUFDLEdBQUcsQ0FBQyxnQkFBZ0IsZ0JBQU0sQ0FBQyxJQUFJLEVBQUUsQ0FBQy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