mirror of
https://github.com/pockethost/pockethost.git
synced 2025-10-14 00:59:25 +00:00
fix: enhance PocketBaseService container rejection handling
This commit is contained in:
parent
6dc7364d23
commit
c985c9061e
@ -42,7 +42,7 @@ export type PocketbaseProcess = {
|
|||||||
url: string
|
url: string
|
||||||
pid: () => string
|
pid: () => string
|
||||||
kill: () => Promise<void>
|
kill: () => Promise<void>
|
||||||
exitCode: Promise<number | null>
|
exitCode: Promise<number>
|
||||||
}
|
}
|
||||||
|
|
||||||
const INSTANCE_IMAGE_NAME = `pockethost-instance`
|
const INSTANCE_IMAGE_NAME = `pockethost-instance`
|
||||||
@ -179,7 +179,7 @@ export const createPocketbaseService = async (
|
|||||||
let started = false
|
let started = false
|
||||||
let stopped = false
|
let stopped = false
|
||||||
const exitCode = new Promise<number>(async (resolveExit) => {
|
const exitCode = new Promise<number>(async (resolveExit) => {
|
||||||
container = await new Promise<Container>((resolve) => {
|
new Promise<Container>((resolveContainer, rejectContainer) => {
|
||||||
docker
|
docker
|
||||||
.run(
|
.run(
|
||||||
INSTANCE_IMAGE_NAME,
|
INSTANCE_IMAGE_NAME,
|
||||||
@ -201,6 +201,7 @@ export const createPocketbaseService = async (
|
|||||||
`${instanceId} stopped unexpectedly with code ${StatusCode} and error ${err}`,
|
`${instanceId} stopped unexpectedly with code ${StatusCode} and error ${err}`,
|
||||||
)
|
)
|
||||||
resolveExit(StatusCode || 999)
|
resolveExit(StatusCode || 999)
|
||||||
|
rejectContainer()
|
||||||
} else {
|
} else {
|
||||||
resolveExit(0)
|
resolveExit(0)
|
||||||
}
|
}
|
||||||
@ -209,14 +210,18 @@ export const createPocketbaseService = async (
|
|||||||
.on('container', (container: Container) => {
|
.on('container', (container: Container) => {
|
||||||
dbg(`Got container`, container)
|
dbg(`Got container`, container)
|
||||||
started = true
|
started = true
|
||||||
resolve(container)
|
resolveContainer(container)
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
if (!container) {
|
.then((_c) => {
|
||||||
iLogger.error(`Could not start container`)
|
dbg(`Container has been assigned`)
|
||||||
error(`${instanceId} could not start container`)
|
container = _c
|
||||||
resolveExit(999)
|
})
|
||||||
}
|
.catch(() => {
|
||||||
|
dbg(`Container will not be assigned`)
|
||||||
|
iLogger.error(`Could not start container`)
|
||||||
|
error(`${instanceId} could not start container`)
|
||||||
|
})
|
||||||
})
|
})
|
||||||
exitCode.then((code) => {
|
exitCode.then((code) => {
|
||||||
iLogger.info(`Process exited with code ${code}`)
|
iLogger.info(`Process exited with code ${code}`)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user