azurite
Version:
An open source Azure Storage API compatible server
72 lines • 3.66 kB
JavaScript
Object.defineProperty(exports, "__esModule", { value: true });
const tslib_1 = require("tslib");
const fs_extra_1 = require("fs-extra");
const path_1 = require("path");
const Logger = tslib_1.__importStar(require("../common/Logger"));
const TableConfiguration_1 = tslib_1.__importDefault(require("./TableConfiguration"));
const TableEnvironment_1 = tslib_1.__importDefault(require("./TableEnvironment"));
const TableServer_1 = tslib_1.__importDefault(require("./TableServer"));
const constants_1 = require("./utils/constants");
const Telemetry_1 = require("../common/Telemetry");
// tslint:disable:no-console
/**
* Entry for Azurite table service
*/
async function main() {
// Initialize the environment from the command line parameters
const env = new TableEnvironment_1.default();
// Check access for process location
const location = await env.location();
await (0, fs_extra_1.ensureDir)(location);
await (0, fs_extra_1.access)(location);
// Check access for debug file path
const debugFilePath = await env.debug();
if (debugFilePath !== undefined) {
await (0, fs_extra_1.ensureDir)((0, path_1.dirname)(debugFilePath));
await (0, fs_extra_1.access)((0, path_1.dirname)(debugFilePath));
}
// Store table configuration
const config = new TableConfiguration_1.default(env.tableHost(), env.tablePort(), env.tableKeepAliveTimeout(), (0, path_1.join)(location, constants_1.DEFAULT_TABLE_LOKI_DB_PATH), (await env.debug()) !== undefined, !env.silent(), undefined, await env.debug(), env.loose(), env.skipApiVersionCheck(), env.cert(), env.key(), env.pwd(), env.oauth(), env.disableProductStyleUrl(), env.inMemoryPersistence());
// We use logger singleton as global debugger logger to track detailed outputs cross layers
// Note that, debug log is different from access log which is only available in request handler layer to
// track every request. Access log is not singleton, and initialized in specific RequestHandlerFactory implementations
// Enable debug log by default before first release for debugging purpose
Logger.configLogger(config.enableDebugLog, config.debugLogFilePath);
// Create server instance
const server = new TableServer_1.default(config);
const beforeStartMessage = `Azurite Table service is starting on ${config.host}:${config.port}`;
const afterStartMessage = `Azurite Table service successfully started on ${config.host}:${config.port}`;
const beforeCloseMessage = `Azurite Table service is closing...`;
const afterCloseMessage = `Azurite Table service successfully closed`;
// Start Server
console.log(beforeStartMessage);
await server.start();
console.log(afterStartMessage);
Telemetry_1.AzuriteTelemetryClient.init(location, !env.disableTelemetry(), env);
await Telemetry_1.AzuriteTelemetryClient.TraceStartEvent("Table");
// Handle close event
process
.once("message", (msg) => {
if (msg === "shutdown") {
console.log(beforeCloseMessage);
Telemetry_1.AzuriteTelemetryClient.TraceStopEvent("Table");
server.close().then(() => {
console.log(afterCloseMessage);
});
}
})
.once("SIGINT", () => {
console.log(beforeCloseMessage);
Telemetry_1.AzuriteTelemetryClient.TraceStopEvent("Table");
server.close().then(() => {
console.log(afterCloseMessage);
});
});
}
main().catch((err) => {
console.error(`Exiting due to an unhandled error: ${err.message}`);
process.exit(1);
});
//# sourceMappingURL=main.js.map
;