Restart on 5 timeouts
This commit is contained in:
parent
4dc71ab0e4
commit
d33be2c3b0
|
@ -9,6 +9,7 @@ import { logError, logInfo, logLow, logSuccess } from './logger'
|
|||
|
||||
import { performance } from 'perf_hooks'
|
||||
import { getSubnetInfo } from './subnetInfo'
|
||||
import { error } from 'console'
|
||||
|
||||
const RECENT_THRESHOLD_IN_MINUTES = 2
|
||||
|
||||
|
@ -18,6 +19,8 @@ const TIMEOUT_IN_MILLISECONDS = process.env.TASK_TIMEOUT || 120000
|
|||
|
||||
let working = false
|
||||
|
||||
let timeoutCount = 0
|
||||
|
||||
const wifiControllers = [unifiController, ciscoController]
|
||||
|
||||
async function getOnlineDevices() {
|
||||
|
@ -198,8 +201,18 @@ function updateDevicesInfo() {
|
|||
working = true
|
||||
|
||||
const updateTimeout = setTimeout(() => {
|
||||
reject('A função atingiu seu tempo limite.')
|
||||
working = false
|
||||
reject('A função atingiu seu tempo limite.')
|
||||
|
||||
timeoutCount++
|
||||
|
||||
if (timeoutCount > 5) {
|
||||
logError({
|
||||
tags: ['wifiDevices'],
|
||||
message: `A função atingiu seu tempo limite ${timeoutCount} vezes. Reiniciando o servidor...`
|
||||
})
|
||||
process.exit(1)
|
||||
}
|
||||
}, TIMEOUT_IN_MILLISECONDS)
|
||||
|
||||
try {
|
||||
|
@ -252,6 +265,7 @@ function updateDevicesInfo() {
|
|||
1000
|
||||
).toFixed(2)}s`
|
||||
})
|
||||
timeoutCount = 0
|
||||
} catch (e) {
|
||||
logError({
|
||||
tags: ['wifiDevices'],
|
||||
|
|
Loading…
Reference in New Issue
Block a user