fix: improved docker launch error messages

This commit is contained in:
Ben Allfree 2023-10-07 07:35:56 -07:00
parent 1f683a37cd
commit 4f1fe0c81e

View File

@ -190,7 +190,7 @@ export const createPocketbaseService = async (
docker docker
.run( .run(
`pockethost/pocketbase`, `pockethost/pocketbase`,
[bin, `--help`], [''], // Supplied by createOptions
[stdout, stderr], [stdout, stderr],
createOptions, createOptions,
(err, data) => { (err, data) => {
@ -198,9 +198,12 @@ export const createPocketbaseService = async (
dbg(`${slug} closed with code ${StatusCode}`, { err, data }) dbg(`${slug} closed with code ${StatusCode}`, { err, data })
isRunning = false isRunning = false
if (StatusCode > 0) { if (StatusCode > 0) {
if (err?.json) {
error(`Error: ${err.json.message}`)
dbg(`${slug} stopped unexpectedly with code ${err}`, data) dbg(`${slug} stopped unexpectedly with code ${err}`, data)
onUnexpectedStop?.(StatusCode, stdoutHistory, stderrHistory)
} }
}
onUnexpectedStop?.(StatusCode, stdoutHistory, stderrHistory)
resolveExit(0) resolveExit(0)
}, },
) )
@ -211,7 +214,9 @@ export const createPocketbaseService = async (
}) })
cm.add(async () => { cm.add(async () => {
dbg(`Stopping ${slug} for cleanup`) dbg(`Stopping ${slug} for cleanup`)
await container?.stop().catch(warn) await container
?.stop()
.catch((err) => warn(`Possible error stopping container: ${err}`))
stderr.off('data', _stdErrData) stderr.off('data', _stdErrData)
stdout.off('data', _stdoutData) stdout.off('data', _stdoutData)
}) })