wechaty-puppet
Version:
Abstract Puppet for Wechaty
35 lines • 1.34 kB
JavaScript
Object.defineProperty(exports, "__esModule", { value: true });
exports.serviceMixin = void 0;
const state_switch_1 = require("state-switch");
const config_js_1 = require("../config.js");
const watchdog_agent_js_1 = require("../agents/watchdog-agent.js");
const serviceMixin = (mixinBase) => {
const serviceBase = (0, state_switch_1.serviceCtlMixin)('PuppetServiceMixin', { log: config_js_1.log })(mixinBase);
let PUPPET_COUNTER = 0;
class ServiceMixin extends serviceBase {
__counter;
__watchdog;
constructor(...args) {
super(...args);
this.__counter = PUPPET_COUNTER++;
config_js_1.log.verbose('PuppetServiceMixin', 'constructor() #%s', this.__counter);
this.__watchdog = new watchdog_agent_js_1.WatchdogAgent(this);
}
async start() {
config_js_1.log.verbose('PuppetServiceMixin', 'start()');
await super.start();
this.__watchdog.start();
this.emit('start');
}
async stop() {
config_js_1.log.verbose('PuppetServiceMixin', 'stop()');
this.__watchdog.stop();
await super.stop();
this.emit('stop');
}
}
return ServiceMixin;
};
exports.serviceMixin = serviceMixin;
//# sourceMappingURL=service-mixin.js.map
;