Fix: dubbele SIGTERM/SIGINT verwijderd (closeSignal blijft)
This commit is contained in:
@@ -33,6 +33,8 @@ function migrateSchema() {
|
|||||||
wins INTEGER NOT NULL DEFAULT 0,
|
wins INTEGER NOT NULL DEFAULT 0,
|
||||||
games INTEGER NOT NULL DEFAULT 0,
|
games INTEGER NOT NULL DEFAULT 0,
|
||||||
avail_mode TEXT NOT NULL DEFAULT 'flex',
|
avail_mode TEXT NOT NULL DEFAULT 'flex',
|
||||||
|
availability_temp TEXT,
|
||||||
|
rejected_slots TEXT,
|
||||||
created_at TEXT NOT NULL DEFAULT (datetime('now'))
|
created_at TEXT NOT NULL DEFAULT (datetime('now'))
|
||||||
);
|
);
|
||||||
|
|
||||||
@@ -99,6 +101,12 @@ function migrateSchema() {
|
|||||||
PRIMARY KEY (player_id, match_id)
|
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 ───
|
// ─── Players ───
|
||||||
@@ -170,13 +178,13 @@ function updatePlayer(id, player) {
|
|||||||
const merged = { ...existing, ...player };
|
const merged = { ...existing, ...player };
|
||||||
db.prepare(`
|
db.prepare(`
|
||||||
UPDATE players SET name=?, level=?, position=?, telegram_id=?, pin=?,
|
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=?
|
WHERE id=?
|
||||||
`).run(
|
`).run(
|
||||||
merged.name, merged.level, merged.position,
|
merged.name, merged.level, merged.position,
|
||||||
String(merged.telegram_id || ''), String(merged.pin || ''),
|
String(merged.telegram_id || ''), String(merged.pin || ''),
|
||||||
merged.sessions, merged.hours, merged.wins, merged.games,
|
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) {
|
if (player.availability !== undefined) {
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ const PORT = 3000;
|
|||||||
|
|
||||||
// Load SQLite db layer (CommonJS module via createRequire)
|
// Load SQLite db layer (CommonJS module via createRequire)
|
||||||
const require = createRequire(import.meta.url);
|
const require = createRequire(import.meta.url);
|
||||||
const db = require("./db/db.cjs");
|
const db = require("./db.cjs");
|
||||||
|
|
||||||
app.use(express.json());
|
app.use(express.json());
|
||||||
app.use(express.static(path.join(__dirname, "..", "public")));
|
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
|
// Graceful shutdown
|
||||||
const closeSignal = (sig) => {
|
const closeSignal = (sig) => {
|
||||||
console.log("Shutting down (" + sig + ")...");
|
console.log("Shutting down (" + sig + ")...");
|
||||||
|
|||||||
Reference in New Issue
Block a user