Fix: dubbele SIGTERM/SIGINT verwijderd (closeSignal blijft)

This commit is contained in:
root
2026-05-25 18:45:42 +00:00
parent c0b33c2144
commit d5fb1404e3
2 changed files with 13 additions and 9 deletions
+12 -4
View File
@@ -32,8 +32,10 @@ function migrateSchema() {
hours INTEGER NOT NULL DEFAULT 0,
wins INTEGER NOT NULL DEFAULT 0,
games INTEGER NOT NULL DEFAULT 0,
avail_mode TEXT NOT NULL DEFAULT 'flex',
created_at TEXT NOT NULL DEFAULT (datetime('now'))
avail_mode TEXT NOT NULL DEFAULT 'flex',
availability_temp TEXT,
rejected_slots TEXT,
created_at TEXT NOT NULL DEFAULT (datetime('now'))
);
CREATE TABLE IF NOT EXISTS player_availability (
@@ -99,6 +101,12 @@ function migrateSchema() {
PRIMARY KEY (player_id, match_id)
);
`);
// Idempotent column migrations
try { db.exec("ALTER TABLE matches ADD COLUMN proposed_teams TEXT"); } catch(e) {}
try { db.exec("ALTER TABLE matches ADD COLUMN players_arr TEXT DEFAULT '[]'"); } catch(e) {}
try { db.exec("ALTER TABLE players ADD COLUMN availability_temp TEXT"); } catch(e) {}
try { db.exec("ALTER TABLE players ADD COLUMN rejected_slots TEXT"); } catch(e) {}
}
// ─── Players ───
@@ -170,13 +178,13 @@ function updatePlayer(id, player) {
const merged = { ...existing, ...player };
db.prepare(`
UPDATE players SET name=?, level=?, position=?, telegram_id=?, pin=?,
sessions=?, hours=?, wins=?, games=?, avail_mode=?, availability_temp=?
sessions=?, hours=?, wins=?, games=?, avail_mode=?, availability_temp=?, rejected_slots=?
WHERE id=?
`).run(
merged.name, merged.level, merged.position,
String(merged.telegram_id || ''), String(merged.pin || ''),
merged.sessions, merged.hours, merged.wins, merged.games,
merged.avail_mode, merged.availability_temp || null, id
merged.avail_mode, merged.availability_temp || null, merged.rejected_slots || null, id
);
if (player.availability !== undefined) {
+1 -5
View File
@@ -11,7 +11,7 @@ const PORT = 3000;
// Load SQLite db layer (CommonJS module via createRequire)
const require = createRequire(import.meta.url);
const db = require("./db/db.cjs");
const db = require("./db.cjs");
app.use(express.json());
app.use(express.static(path.join(__dirname, "..", "public")));
@@ -561,10 +561,6 @@ app.listen(PORT, () => {
});
// Graceful shutdown
process.on("SIGTERM", () => { console.log("Shutting down..."); db.close(); process.exit(0); });
process.on("SIGINT", () => { console.log("Shutting down..."); db.close(); process.exit(0); });
// Graceful shutdown
const closeSignal = (sig) => {
console.log("Shutting down (" + sig + ")...");