Skip to content

Commit

Permalink
make servicesInfo intervals be configgable
Browse files Browse the repository at this point in the history
  • Loading branch information
onlypuppy7 committed Nov 19, 2024
1 parent 588294c commit 64f8470
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 5 deletions.
8 changes: 6 additions & 2 deletions server-client/start-client.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ export default async function run () {
let retrieved = false;
let offline = false;

var servicesInfo = "";

await plugins.emit('onLoad', { ss });

async function startServer() {
Expand Down Expand Up @@ -275,9 +277,11 @@ export default async function run () {
var info = {
...msg.client,
};
if (Object.keys(info.gameInfo).length !== 0) {
fs.writeFileSync(path.join(ss.currentDir, 'store', 'client-modified', 'servicesInfo.json'), JSON.stringify(info));
var newServicesInfo = JSON.stringify(info);
if (Object.keys(info.gameInfo).length !== 0 && servicesInfo !== newServicesInfo) {
fs.writeFileSync(path.join(ss.currentDir, 'store', 'client-modified', 'servicesInfo.json'), newServicesInfo);
};
servicesInfo = newServicesInfo;
break;
default:
log.error(`Unknown command received: ${msg.cmd}`);
Expand Down
2 changes: 1 addition & 1 deletion server-game/src/roomManager.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ class newRoomManager {
this.sendInfoToServices();
setInterval(() => {
this.sendInfoToServices();
}, 30e3);
}, ss.config.game.servicesInfoCollectInterval * 1e3);
};

getUnusedID() {
Expand Down
2 changes: 1 addition & 1 deletion server-services/start-services.js
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,7 @@ export default async function run () {
} else {
sendServicesInfo();
};
}, 10e3);
}, ss.config.distributed_all.servicesInfoSendInterval * 1e3);
} else if (ss.config.distributed_all.closed !== true) {
switch (msg.cmd) {
// Game server commands
Expand Down
8 changes: 7 additions & 1 deletion src/defaultconfig/distributed_all.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
#this is what the other servers will ping this server for

closed: false # shuts down services/game and displays a closed message on the webpage.
closed: false # shuts down services/game and displays a closed message on the webpage.

# interval in seconds in which game/client servers report stats to the services server
servicesInfoCollectInterval: 15

# interval in seconds in which the services server sends specific stats back to game/client servers
servicesInfoSendInterval: 10

0 comments on commit 64f8470

Please sign in to comment.