Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 1 addition & 4 deletions plugin/src/channel-plugin-api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -135,10 +135,7 @@ export function buildPilotChannelPlugin(deps: BuildPilotPluginDeps): PilotChanne
accountId: string;
}) => {
deps.logger.info("pilot channel: account changed, reloading", { accountId });
const acct = lifecycle.getAccount(accountId);
if (acct) {
await acct.transport.stop();
}
await lifecycle.stopAccount(accountId);
await lifecycle.startAll(nextCfg);
},
onAccountRemoved: async ({ accountId }: { accountId: string }) => {
Expand Down
13 changes: 13 additions & 0 deletions plugin/src/lifecycle.ts
Original file line number Diff line number Diff line change
Expand Up @@ -275,6 +275,19 @@ export class PilotLifecycle {
return this.accounts.get(accountId)?.outbox;
}

/** Stop a single account and remove it from the live map. */
async stopAccount(accountId: string): Promise<void> {
const state = this.accounts.get(accountId);
if (!state) return;
try {
if (state.drainTimer) clearInterval(state.drainTimer);
state.pipeline.stop();
await state.transport.stop();
} finally {
this.accounts.delete(accountId);
}
}

async stopAll(): Promise<void> {
const tasks: Promise<void>[] = [];
for (const [id, state] of this.accounts) {
Expand Down
Loading