"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); const IO_KEY = Symbol.for('@pm2/io'); class Entrypoint { constructor() { try { this.io = global[IO_KEY].init(this.conf()); this.onStart(err => { if (err) { console.error(err); process.exit(1); } this.sensors(); this.events(); this.actuators(); this.io.onExit((code, signal) => { this.onStop(err, () => { this.io.destroy(); }, code, signal); }); if (process && process.send) process.send('ready'); }); } catch (e) { if (this.io) { this.io.destroy(); } throw (e); } } events() { return; } sensors() { return; } actuators() { return; } onStart(cb) { throw new Error('Entrypoint onStart() not specified'); } onStop(err, cb, code, signal) { return cb(); } conf() { return undefined; } } exports.Entrypoint = Entrypoint; //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiZW50cnlwb2ludC5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uLy4uL3NyYy9mZWF0dXJlcy9lbnRyeXBvaW50LnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7O0FBRUEsTUFBTSxNQUFNLEdBQUcsTUFBTSxDQUFDLEdBQUcsQ0FBQyxTQUFTLENBQUMsQ0FBQTtBQUVwQyxNQUFhLFVBQVU7SUFHckI7UUFDRSxJQUFJO1lBQ0YsSUFBSSxDQUFDLEVBQUUsR0FBRyxNQUFNLENBQUMsTUFBTSxDQUFDLENBQUMsSUFBSSxDQUFDLElBQUksQ0FBQyxJQUFJLEVBQUUsQ0FBQyxDQUFBO1lBRTFDLElBQUksQ0FBQyxPQUFPLENBQUMsR0FBRyxDQUFDLEVBQUU7Z0JBQ2pCLElBQUksR0FBRyxFQUFFO29CQUNQLE9BQU8sQ0FBQyxLQUFLLENBQUMsR0FBRyxDQUFDLENBQUE7b0JBQ2xCLE9BQU8sQ0FBQyxJQUFJLENBQUMsQ0FBQyxDQUFDLENBQUE7aUJBQ2hCO2dCQUVELElBQUksQ0FBQyxPQUFPLEVBQUUsQ0FBQTtnQkFDZCxJQUFJLENBQUMsTUFBTSxFQUF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