Skip to content

Commit

Permalink
Fix
Browse files Browse the repository at this point in the history
  • Loading branch information
nzws committed May 13, 2024
1 parent 5f9f046 commit 0665782
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
4 changes: 2 additions & 2 deletions apps/push-serverless/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,6 @@ const port = process.env.PORT || 8000;
const server = app.listen(port);
console.log(`Listening on port ${port}`);

new Streaming(server);

const autoSleep = setInterval(() => {
if (isServerIdling()) {
console.log('all lives ended, stopping server');
Expand All @@ -70,3 +68,5 @@ process.on('SIGTERM', () => {
server.close();
process.exit(0);
});

new Streaming(server);
1 change: 1 addition & 0 deletions apps/push-serverless/src/utils/sessions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ export const lives = new Map<
>();

export const isServerIdling = () => {
console.log('sessions', sessions.size, 'lives', lives.size);
return sessions.size === 0 && lives.size === 0;
};

Expand Down

0 comments on commit 0665782

Please sign in to comment.