feat: decouple OTA updates into dedicated fast endpoints to avoid db timeouts
This commit is contained in:
+13
-3
@@ -151,6 +151,18 @@ const resolveCurrentStationCode = (body, resolveStation) => {
|
||||
return codes[0] || direct || fallback || '';
|
||||
};
|
||||
|
||||
// Dedicated lightweight OTA update endpoints
|
||||
let globalUpdateCounter = Date.now();
|
||||
|
||||
router.post('/trigger-update', (req, res) => {
|
||||
globalUpdateCounter++;
|
||||
res.json({ ok: true, update_counter: globalUpdateCounter });
|
||||
});
|
||||
|
||||
router.get('/check-update', (req, res) => {
|
||||
res.json({ update_counter: globalUpdateCounter });
|
||||
});
|
||||
|
||||
// Config
|
||||
router.get('/config', (req, res) => {
|
||||
const cfg = DataService.getConfig();
|
||||
@@ -190,9 +202,7 @@ router.put('/config', async (req, res) => {
|
||||
if (typeof incoming.force_update === 'boolean') {
|
||||
cfg.force_update = incoming.force_update;
|
||||
}
|
||||
if (incoming.update_counter) {
|
||||
cfg.update_counter = incoming.update_counter;
|
||||
}
|
||||
// remove unused update_counter
|
||||
await DataService.saveConfig(cfg);
|
||||
appendReqLog(req, { category: 'admin', type: 'update_config_generic', detail: incoming });
|
||||
io.emit('config:updated', cfg);
|
||||
|
||||
Reference in New Issue
Block a user