import '../WorkerInit.js';
import { SupervisorDefinition } from '@devvit/protos/types/devvit/runtime/actor/supervisor.js';
import { SupervisorActor } from '../../common/actors/SupervisorActor.js';
import { WorkerDispatcher } from '../../common/envelope/dispatcher/WorkerDispatcher.js';
import { EnvelopeServerBuilder } from '../../common/envelope/EnvelopeServerBuilder.js';
import { Log } from '../../lib/loggers/Log.js';
// self.name is the full hostname
const dispatcher = new WorkerDispatcher(self.name);
dispatcher.bindToWorkerPort(self);
const supervisor = new SupervisorActor(dispatcher);
const server = EnvelopeServerBuilder.build(self.name, [SupervisorDefinition], supervisor);
dispatcher.bind(server);
Log.info(`${self.name} ready.`);
