fix(sync): retry failed saves every 5 s; restart the decoder simulator with the server (1.65.5)
This commit is contained in:
1 parent
fed83ddf67
commit
54f4c3b923
7 files changed
+44
-6
No files matched your search
@@ -773,7 +773,22 @@ app.use((_req, res) => {
|
||||
res.sendFile(path.join(__dirname, "index.html"));
|
||||
});
|
||||
|
||||
// The simulator was on before a restart (Settings keep the real decoder address while it is):
|
||||
// start it again so the app finds it.
|
||||
function restartDecoderSimIfOn() {
|
||||
try {
|
||||
const row = db.prepare("SELECT state_json FROM app_state WHERE id = 1").get();
|
||||
const settings = row ? JSON.parse(row.state_json)?.settings : null;
|
||||
if (!settings?.simPreviousWsUrl && !/:9099\/?$/.test(String(settings?.wsUrl || ""))) return;
|
||||
decoderSim.start({ port: 9099, host: HOST, lapSec: settings.simLapSec || 18, spreadSec: settings.simSpreadSec ?? 1.5 })
|
||||
.catch((error) => console.error(`Decoder simulator could not start again: ${error.message}`));
|
||||
} catch (error) {
|
||||
console.error(`Decoder simulator check failed: ${error.message}`);
|
||||
}
|
||||
}
|
||||
|
||||
app.listen(PORT, HOST, () => {
|
||||
restartDecoderSimIfOn();
|
||||
writePidFile();
|
||||
console.log(`RC Timing server listening on http://${HOST}:${PORT}`);
|
||||
const lanUrls = getLanUrls(PORT);
|
||||
|
||||
Reference in new issue
Block a user