"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
const path_1 = require("path");
const shardus_1 = __importDefault(require("./shardus"));
const utils_1 = require("./utils");
const baseDirPath = (0, path_1.resolve)(process.argv[2] || './');
// if configs exist in baseDir, use them
// if not, use default configs
let config;
try {
    config = (0, utils_1.readJSONDir)((0, path_1.join)(baseDirPath, 'config'));
    if (Object.keys(config).length === 0 && config.constructor === Object)
        throw new Error('Empty configs');
}
catch (e) {
    config = (0, utils_1.readJSONDir)((0, path_1.join)(__dirname, 'config'));
}
config.server.baseDir = baseDirPath;
const shardus = new shardus_1.default(config);
async function init() {
    shardus.setup(null);
    await shardus.start();
    shardus.registerExceptionHandler();
}
init();
//# sourceMappingURL=server.js.map