Skip to content

Commit

Permalink
statsd fix attempt #1
Browse files Browse the repository at this point in the history
  • Loading branch information
timolegros committed Jul 26, 2024
1 parent ce81b7e commit 759ac65
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
4 changes: 4 additions & 0 deletions libs/core/src/ports/port.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,10 @@ const disposeAndExit = async (
// don't kill process when errors are caught in production
if (code === 'ERROR' && config.NODE_ENV === 'production' && !forceExit)
return;
else if (code === 'ERROR' && config.NODE_ENV === 'production' && forceExit) {
// sleep for 1 second to allow stat metrics to flush
await new Promise((resolve) => setTimeout(resolve, 1_000));
}

// call disposers
await Promise.all(disposers.map((disposer) => disposer()));
Expand Down
3 changes: 2 additions & 1 deletion packages/commonwealth/scripts/archive-outbox.ts
Original file line number Diff line number Diff line change
Expand Up @@ -207,10 +207,11 @@ async function main() {
if (import.meta.url.endsWith(process.argv[1])) {
main()
.then(async () => {
stats(HotShotsStats()).increment('cw.scheduler.archive-outbox');
stats(HotShotsStats()).on('cw.scheduler.archive-outbox');
await dispose()('EXIT', true);
})
.catch(async (err) => {
stats(HotShotsStats()).off('cw.scheduler.archive-outbox');
log.fatal('Failed to archive outbox child partitions to S3', err);
await dispose()('ERROR', true);
});
Expand Down

0 comments on commit 759ac65

Please sign in to comment.