mirror of
https://github.com/pockethost/pockethost.git
synced 2025-05-19 21:36:40 +00:00
fix: maintenance mode timeout fixed
This commit is contained in:
parent
5c0a233067
commit
80af61d118
@ -94,9 +94,15 @@ export const instanceService = mkSingleton(
|
|||||||
retry(0)
|
retry(0)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if (instanceApi.status() === InstanceApiStatus.Healthy) {
|
try {
|
||||||
dbg(`API found and healthy, returning`)
|
if (instanceApi.status() === InstanceApiStatus.Healthy) {
|
||||||
resolve(instanceApi)
|
dbg(`API found and healthy, returning`)
|
||||||
|
resolve(instanceApi)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
} catch (e) {
|
||||||
|
dbg(`Instance is in an error state, returning error`)
|
||||||
|
reject(e)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
dbg(`API found but not healthy, waiting`)
|
dbg(`API found but not healthy, waiting`)
|
||||||
@ -144,8 +150,10 @@ export const instanceService = mkSingleton(
|
|||||||
/*
|
/*
|
||||||
Initialize API
|
Initialize API
|
||||||
*/
|
*/
|
||||||
|
let _shutdownReason: Error | undefined
|
||||||
const api: InstanceApi = {
|
const api: InstanceApi = {
|
||||||
status: () => {
|
status: () => {
|
||||||
|
if (_shutdownReason) throw _shutdownReason
|
||||||
return status
|
return status
|
||||||
},
|
},
|
||||||
internalUrl: () => {
|
internalUrl: () => {
|
||||||
@ -166,18 +174,20 @@ export const instanceService = mkSingleton(
|
|||||||
},
|
},
|
||||||
shutdown: async (reason) => {
|
shutdown: async (reason) => {
|
||||||
if (reason) {
|
if (reason) {
|
||||||
|
_shutdownReason = reason
|
||||||
error(`Panic shutdown for ${reason}`)
|
error(`Panic shutdown for ${reason}`)
|
||||||
} else {
|
} else {
|
||||||
dbg(`Graceful shutdown`)
|
dbg(`Graceful shutdown`)
|
||||||
}
|
}
|
||||||
if (api.status() === InstanceApiStatus.ShuttingDown) {
|
if (status === InstanceApiStatus.ShuttingDown) {
|
||||||
throw new Error(`Already shutting down`)
|
warn(`Already shutting down`)
|
||||||
|
return
|
||||||
}
|
}
|
||||||
return shutdownManager.shutdown()
|
return shutdownManager.shutdown()
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
const _safeShutdown = async (reason?: Error) => {
|
const _safeShutdown = async (reason?: Error) => {
|
||||||
if (api.status() === InstanceApiStatus.ShuttingDown) {
|
if (status === InstanceApiStatus.ShuttingDown) {
|
||||||
warn(`Already shutting down, ${reason} will not be reported.`)
|
warn(`Already shutting down, ${reason} will not be reported.`)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@ -186,7 +196,7 @@ export const instanceService = mkSingleton(
|
|||||||
instanceApis[id] = api
|
instanceApis[id] = api
|
||||||
|
|
||||||
const healthyGuard = () => {
|
const healthyGuard = () => {
|
||||||
if (api.status() !== InstanceApiStatus.ShuttingDown) return
|
if (status !== InstanceApiStatus.ShuttingDown) return
|
||||||
throw new Error(
|
throw new Error(
|
||||||
`HealthyGuard detected instance is shutting down. Aborting further initialization.`
|
`HealthyGuard detected instance is shutting down. Aborting further initialization.`
|
||||||
)
|
)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user