Skip to content

Commit

Permalink
fix lint
Browse files Browse the repository at this point in the history
  • Loading branch information
aaronkvanmeerten committed Apr 19, 2024
1 parent e4247ee commit 33eea65
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 7 deletions.
14 changes: 8 additions & 6 deletions src/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -100,22 +100,24 @@ async function jibriStateWebhook(req: Request, res: Response) {
*/
async function instanceShutdownWebhook(req: Request, res: Response) {
// update global stats report with
if (!shutdownReported) {
if (shutdownReported) {
res.status(200);
shutdownReported = true;
res.send('{"status":"OK", "message":"Already reported shutdown"}');
} else {
const ret = await autoscalePoller.reportShutdown();

if (ret) {
res.status(200);
shutdownReported = true;
res.send('{"status":"OK"}');
} else {
res.status(500);
res.send('{"status":"FAILED"}');
}
} else {
res.status(200);
shutdownReported = true;
res.send('{"status":"OK", "message":"Already reported shutdown"}');
}
}
}

/**
* Polls stats every 1 second.
*/
Expand Down
4 changes: 3 additions & 1 deletion src/autoscale_poller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,14 +58,16 @@ export default class AutoscalePoller {
async reportShutdown(): Promise<boolean> {
try {
if (!this.shutdownUrl) {
throw({'code':'NO_SHUTDOWN_URL','message': 'No shutdown URL configured'});
throw new Error('No shutdown URL configured');
}
await this.asapRequest.postJson(this.shutdownUrl, this.instanceDetails);

return true;
} catch (err) {
logger.error('Error sending shutdown report', { err,
traceback: err.traceback });
}

return false;
}

Expand Down
3 changes: 3 additions & 0 deletions src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,13 @@ export default {

// number of seconds to wait between polling for shutdown
ShutdownPollingInterval: env.SHUTDOWN_POLLING_INTERVAL,

// url for reporting final shutdown
ShutdownURL: env.SHUTDOWN_URL,

// url to poll for server commands
PollingURL: env.POLLING_URL,

// url to report status and stats
StatusURL: env.STATUS_URL,

Expand Down

0 comments on commit 33eea65

Please sign in to comment.