Skip to content

Commit

Permalink
restart on 'uncaughtException'
Browse files Browse the repository at this point in the history
  • Loading branch information
vincss committed Apr 24, 2023
1 parent f26b968 commit 4d089b8
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 5 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,8 @@ Give a ⭐️ if you like the project!
[![Donate](https://img.shields.io/badge/Donate-PayPal-green.svg)](https://paypal.me/vincss)

## 📜 ChangeLog
* 1.5.7 - 1.19.3 :
- restart on 'uncaughtException'
* 1.5.6 - 1.19.3 :
- do not exit on 'uncaughtException'
* 1.5.5 - 1.19.3 :
Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "mcsleepingserverstarter",
"version": "1.5.6",
"version": "1.5.7",
"description": "Sleeps until someone connects",
"main": "build/sleepingServerStarter.js",
"bin": "build/sleepingServerStarter.js",
Expand Down
2 changes: 1 addition & 1 deletion src/sleepingContainer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import { getSettings, Settings } from './sleepingSettings';
import { PlayerConnectionCallBackType } from './sleepingTypes';
import { SleepingWeb } from './sleepingWeb';

const MC_TIMEOUT = 5000;
export const MC_TIMEOUT = 5000;

export class SleepingContainer implements ISleepingServer {

Expand Down
10 changes: 9 additions & 1 deletion src/sleepingServerStarter.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { SleepingContainer } from './sleepingContainer';
import { MC_TIMEOUT, SleepingContainer } from './sleepingContainer';
import { getLogger, LoggerType } from './sleepingLogger';
import { Settings } from './sleepingSettings';

Expand Down Expand Up @@ -33,6 +33,14 @@ process.on('uncaughtException', (err: Error) => {
) {
logger.error('[Main] Something bad happened', err.message);
}


logger.info(`[Main] ... Restarting the server in (${MC_TIMEOUT / 1000} secs)...`);
setTimeout(async () => {
await sleepingContainer.close(true);
sleepingContainer.init(true);
}, MC_TIMEOUT);

});

const close = async () => {
Expand Down

0 comments on commit 4d089b8

Please sign in to comment.