Skip to content

Commit

Permalink
fix(repeater): show repeater started message after first deploy (#485)
Browse files Browse the repository at this point in the history
fixes #486
  • Loading branch information
lsndr authored Oct 24, 2023
1 parent c477f62 commit 02e71f3
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions src/Repeater/ServerRepeaterLauncher.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import chalk from 'chalk';
export class ServerRepeaterLauncher implements RepeaterLauncher {
private static SERVICE_NAME = 'bright-repeater';
private repeaterStarted: boolean = false;
private repeaterRunning: boolean = false;
private repeaterId: string | undefined;

constructor(
Expand All @@ -36,6 +37,7 @@ export class ServerRepeaterLauncher implements RepeaterLauncher {
) {}

public close() {
this.repeaterRunning = false;
this.repeaterStarted = false;
this.repeaterServer.disconnect();

Expand Down Expand Up @@ -83,10 +85,12 @@ export class ServerRepeaterLauncher implements RepeaterLauncher {
repeaterId: string,
asDaemon: boolean = false
): Promise<void> {
if (this.repeaterStarted) {
if (this.repeaterRunning) {
return;
}

this.repeaterRunning = true;

if (asDaemon) {
await this.startupManager.run(() => this.close());
}
Expand All @@ -96,9 +100,6 @@ export class ServerRepeaterLauncher implements RepeaterLauncher {
this.repeaterId = repeaterId;
this.repeaterServer.connect(repeaterId);
this.subscribeToEvents();
this.repeaterStarted = true;

logger.log(`The Repeater (%s) started`, this.info.version);
}

private getRuntime(): DeploymentRuntime {
Expand All @@ -122,6 +123,12 @@ export class ServerRepeaterLauncher implements RepeaterLauncher {
},
this.getRuntime()
);

if (!this.repeaterStarted) {
this.repeaterStarted = true;

logger.log('The Repeater (%s) started', this.info.version);
}
});
this.repeaterServer.errorOccurred(({ message }) => {
logger.error(`%s: %s`, chalk.red('(!) CRITICAL'), message);
Expand Down

0 comments on commit 02e71f3

Please sign in to comment.