coldown fix
This commit is contained in:
@@ -3,6 +3,8 @@ import { registerRoutes } from "./routes";
|
||||
import { setupVite, serveStatic, log } from "./vite";
|
||||
import { setupKeycloak } from "./keycloak";
|
||||
import { config } from "./config";
|
||||
import { storage } from "./storage";
|
||||
import { CanvasExporter } from "./export";
|
||||
|
||||
const app = express();
|
||||
app.use(express.json());
|
||||
@@ -15,7 +17,7 @@ if (config.enableKeycloak) {
|
||||
process.env.KEYCLOAK_REALM = config.keycloakRealm;
|
||||
process.env.KEYCLOAK_AUTH_URL = config.keycloakAuthUrl;
|
||||
process.env.KEYCLOAK_CLIENT_ID = config.keycloakClientId;
|
||||
|
||||
|
||||
keycloak = setupKeycloak(app);
|
||||
log("Keycloak authentication enabled");
|
||||
} else {
|
||||
@@ -72,6 +74,42 @@ app.use((req, res, next) => {
|
||||
serveStatic(app);
|
||||
}
|
||||
|
||||
// Aktualisiere Canvas-Konfiguration beim Start falls sich config.cfg geändert hat
|
||||
try {
|
||||
const currentConfig = await storage.getCanvasConfig();
|
||||
const configChanged =
|
||||
currentConfig.canvasWidth !== config.canvasWidth ||
|
||||
currentConfig.canvasHeight !== config.canvasHeight ||
|
||||
currentConfig.defaultCooldown !== config.defaultCooldown ||
|
||||
currentConfig.enableAutomaticEvents !== config.enableAutomaticEvents ||
|
||||
currentConfig.eventDuration !== config.eventDurationMinutes ||
|
||||
currentConfig.eventInterval !== config.eventIntervalHours;
|
||||
|
||||
if (configChanged) {
|
||||
console.log(`${formatTime()} [express] Aktualisiere Canvas-Konfiguration aus config.cfg`);
|
||||
|
||||
// Für SQLite Storage: Verwende expandCanvas wenn Canvas vergrößert wird
|
||||
if ('expandCanvas' in storage && typeof storage.expandCanvas === 'function' &&
|
||||
(config.canvasWidth > currentConfig.canvasWidth || config.canvasHeight > currentConfig.canvasHeight)) {
|
||||
await (storage as any).expandCanvas(config.canvasWidth, config.canvasHeight);
|
||||
} else {
|
||||
await storage.updateCanvasConfig({
|
||||
canvasWidth: Math.max(currentConfig.canvasWidth, config.canvasWidth), // Erlaube nur Erweiterung
|
||||
canvasHeight: Math.max(currentConfig.canvasHeight, config.canvasHeight), // Erlaube nur Erweiterung
|
||||
defaultCooldown: config.defaultCooldown,
|
||||
enableAutomaticEvents: config.enableAutomaticEvents,
|
||||
eventDuration: config.eventDurationMinutes,
|
||||
eventInterval: config.eventIntervalHours
|
||||
});
|
||||
}
|
||||
console.log(`${formatTime()} [express] Canvas-Konfiguration aktualisiert`);
|
||||
}
|
||||
} catch (error) {
|
||||
console.error(`${formatTime()} [express] Fehler beim Aktualisieren der Canvas-Konfiguration:`, error);
|
||||
}
|
||||
|
||||
// Canvas exporter wird bereits in routes.ts initialisiert
|
||||
|
||||
// ALWAYS serve the app on the port specified in the environment variable PORT
|
||||
// Other ports are firewalled. Default to 5000 if not specified.
|
||||
// this serves both the API and the client.
|
||||
@@ -85,3 +123,11 @@ app.use((req, res, next) => {
|
||||
log(`serving on port ${port}`);
|
||||
});
|
||||
})();
|
||||
|
||||
function formatTime() {
|
||||
const now = new Date();
|
||||
const hours = String(now.getHours()).padStart(2, '0');
|
||||
const minutes = String(now.getMinutes()).padStart(2, '0');
|
||||
const seconds = String(now.getSeconds()).padStart(2, '0');
|
||||
return `[${hours}:${minutes}:${seconds}]`;
|
||||
}
|
||||
Reference in New Issue
Block a user