fix: reset is_online on server start, reduce heartbeat to 20s

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-03-27 20:08:43 +03:00
parent 0e51f8326a
commit 83eff2b0c6
2 changed files with 5 additions and 1 deletions

View File

@@ -72,7 +72,7 @@ export function registerAgentWs(fastify: FastifyInstance) {
socket.isAlive = false socket.isAlive = false
socket.ping() socket.ping()
}) })
}, 30000) }, 20000)
wss.on('close', () => clearInterval(heartbeat)) wss.on('close', () => clearInterval(heartbeat))
} }

View File

@@ -24,6 +24,10 @@ async function main() {
await runMigrations() await runMigrations()
await seedIfEmpty() await seedIfEmpty()
// При рестарте сервера все агенты считаются офлайн — они переподключатся сами
await db.query('UPDATE workstations SET is_online = false').catch(() => {})
console.log('[server] Reset all workstations to offline')
await redis.connect() await redis.connect()
console.log('[redis] Connected') console.log('[redis] Connected')