@malagu/core
Version:
55 lines • 2.4 kB
JavaScript
;
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
return c > 3 && r && Object.defineProperty(target, key, r), r;
};
var __metadata = (this && this.__metadata) || function (k, v) {
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
};
var BackendApplication_1;
Object.defineProperty(exports, "__esModule", { value: true });
exports.BackendApplication = void 0;
const common_1 = require("../../common");
const backend_application_state_1 = require("./backend-application-state");
let BackendApplication = BackendApplication_1 = class BackendApplication extends common_1.AbstractApplication {
async start() {
this.setupExitSignals();
await this.doStart();
this.stateService.state = 'started';
this.stateService.state = 'ready';
}
removeListeners(event) {
for (const l of process.listeners(event)) {
if (l._tag === BackendApplication_1.name) {
process.removeListener(event, l);
}
}
}
setupExitSignals() {
this.removeListeners('SIGINT');
this.removeListeners('SIGTERM');
const l = this.doExit.bind(this);
l._tag = BackendApplication_1.name;
process.once('SIGINT', l);
process.once('SIGTERM', l);
}
doExit() {
this.doStop();
process.exit(0);
}
async stop() {
this.doStop();
this.stateService.state = 'stoped';
}
};
__decorate([
(0, common_1.Autowired)(common_1.ApplicationStateService),
__metadata("design:type", backend_application_state_1.BackendApplicationStateService)
], BackendApplication.prototype, "stateService", void 0);
BackendApplication = BackendApplication_1 = __decorate([
(0, common_1.Component)(common_1.Application)
], BackendApplication);
exports.BackendApplication = BackendApplication;
//# sourceMappingURL=backend-application.js.map