mirror of
https://github.com/pockethost/pockethost.git
synced 2025-07-08 22:02:33 +00:00
chore: enhance debug logging in InstanceService
This commit is contained in:
parent
ccb9fa892c
commit
30a1964a66
@ -77,7 +77,11 @@ export const instanceService = mkSingleton(
|
|||||||
const retry = (interval = instanceApiCheckIntervalMs) => {
|
const retry = (interval = instanceApiCheckIntervalMs) => {
|
||||||
maxTries--
|
maxTries--
|
||||||
if (maxTries <= 0) {
|
if (maxTries <= 0) {
|
||||||
reject(new Error(`Timeout obtaining instance API.`))
|
reject(
|
||||||
|
new Error(
|
||||||
|
`Timeout obtaining instance API: [${id}:${subdomain}].`,
|
||||||
|
),
|
||||||
|
)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
dbg(`${maxTries} tries remaining. Retrying in ${interval}ms`)
|
dbg(`${maxTries} tries remaining. Retrying in ${interval}ms`)
|
||||||
@ -103,7 +107,7 @@ export const instanceService = mkSingleton(
|
|||||||
reject(e)
|
reject(e)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
dbg(`API found but not healthy, waiting`)
|
dbg(`API found but not healthy (${instanceApi.status()}), waiting`)
|
||||||
retry()
|
retry()
|
||||||
}
|
}
|
||||||
_check()
|
_check()
|
||||||
@ -128,13 +132,22 @@ export const instanceService = mkSingleton(
|
|||||||
Initialize shutdown manager
|
Initialize shutdown manager
|
||||||
*/
|
*/
|
||||||
const shutdownManager = createCleanupManager()
|
const shutdownManager = createCleanupManager()
|
||||||
shutdownManager.add(async () => {
|
shutdownManager.add(() => {
|
||||||
dbg(`Deleting from cache`)
|
dbg(`Shutting down: delete instanceApis[id]`)
|
||||||
|
dbg(
|
||||||
|
`Shutting down: There are ${
|
||||||
|
values(instanceApis).length
|
||||||
|
} still in API cache`,
|
||||||
|
)
|
||||||
delete instanceApis[id]
|
delete instanceApis[id]
|
||||||
dbg(`There are ${values(instanceApis).length} still in cache`)
|
dbg(
|
||||||
|
`Shutting down: There are now ${
|
||||||
|
values(instanceApis).length
|
||||||
|
} still in API cache`,
|
||||||
|
)
|
||||||
}, CLEANUP_PRIORITY_LAST) // Make this the very last thing that happens
|
}, CLEANUP_PRIORITY_LAST) // Make this the very last thing that happens
|
||||||
shutdownManager.add(async () => {
|
shutdownManager.add(() => {
|
||||||
dbg(`Shutting down`)
|
dbg(`Shut down: InstanceApiStatus.ShuttingDown`)
|
||||||
status = InstanceApiStatus.ShuttingDown
|
status = InstanceApiStatus.ShuttingDown
|
||||||
})
|
})
|
||||||
|
|
||||||
@ -222,7 +235,7 @@ export const instanceService = mkSingleton(
|
|||||||
dbg(`Obtaining port`)
|
dbg(`Obtaining port`)
|
||||||
const [newPort, releasePort] = await PortService().alloc()
|
const [newPort, releasePort] = await PortService().alloc()
|
||||||
shutdownManager.add(() => {
|
shutdownManager.add(() => {
|
||||||
dbg(`Releasing port`)
|
dbg(`shut down: releasing port`)
|
||||||
releasePort()
|
releasePort()
|
||||||
}, CLEANUP_PRIORITY_LAST)
|
}, CLEANUP_PRIORITY_LAST)
|
||||||
systemInstanceLogger.breadcrumb(`port:${newPort}`)
|
systemInstanceLogger.breadcrumb(`port:${newPort}`)
|
||||||
@ -242,7 +255,7 @@ export const instanceService = mkSingleton(
|
|||||||
healthyGuard()
|
healthyGuard()
|
||||||
await updateInstanceStatus(instance.id, InstanceStatus.Starting)
|
await updateInstanceStatus(instance.id, InstanceStatus.Starting)
|
||||||
shutdownManager.add(async () => {
|
shutdownManager.add(async () => {
|
||||||
dbg(`Set instance status: idle`)
|
dbg(`Shutting down: set instance status: idle`)
|
||||||
await updateInstanceStatus(id, InstanceStatus.Idle).catch(error)
|
await updateInstanceStatus(id, InstanceStatus.Idle).catch(error)
|
||||||
})
|
})
|
||||||
healthyGuard()
|
healthyGuard()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user