Skip to content

Commit

Permalink
reload settings on restart
Browse files Browse the repository at this point in the history
  • Loading branch information
vwi committed May 2, 2023
1 parent 4d089b8 commit e951d5c
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 4 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.8 - 1.19.3 :
- reload settings on restart
* 1.5.7 - 1.19.3 :
- restart on 'uncaughtException'
* 1.5.6 - 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.7",
"version": "1.5.8",
"description": "Sleeps until someone connects",
"main": "build/sleepingServerStarter.js",
"bin": "build/sleepingServerStarter.js",
Expand Down
6 changes: 5 additions & 1 deletion src/sleepingContainer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ export class SleepingContainer implements ISleepingServer {

this.logger.info(`[Container] ...Time to kill me if you want (${MC_TIMEOUT / 1000} secs)...`);
setTimeout(async () => {
this.settings = getSettings();
this.reloadSettings();
this.logger.info('[Container] ...Too late !...');
await this.init();
}, MC_TIMEOUT); // restart server
Expand All @@ -155,6 +155,10 @@ export class SleepingContainer implements ISleepingServer {
}
};

reloadSettings = () => {
this.settings = getSettings();
}

getStatus = async () => {
let status = ServerStatus.Stopped;
if (this.mcServer) {
Expand Down
1 change: 1 addition & 0 deletions src/sleepingServerStarter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ process.on('uncaughtException', (err: Error) => {
logger.info(`[Main] ... Restarting the server in (${MC_TIMEOUT / 1000} secs)...`);
setTimeout(async () => {
await sleepingContainer.close(true);
sleepingContainer.reloadSettings();
sleepingContainer.init(true);
}, MC_TIMEOUT);

Expand Down

0 comments on commit e951d5c

Please sign in to comment.