fix update spawn error handling and reset flag
This commit is contained in:
parent
61c0c90695
commit
d2339b8d44
|
|
@ -304,9 +304,16 @@ router.get('/update', async c => {
|
|||
router.post('/update', c => {
|
||||
if (isUpdating) return c.json({ ok: false, error: 'update already in progress' }, 409)
|
||||
isUpdating = true
|
||||
try {
|
||||
const script = join(projectRoot, 'install/install.sh')
|
||||
Bun.spawn(['bash', script], { cwd: projectRoot, stdout: 'ignore', stderr: 'ignore' })
|
||||
const proc = Bun.spawn(['bash', script], { cwd: projectRoot, stdout: 'ignore', stderr: 'ignore' })
|
||||
proc.exited.then(code => { if (code !== 0) isUpdating = false })
|
||||
.catch(() => { isUpdating = false })
|
||||
return c.json({ ok: true })
|
||||
} catch {
|
||||
isUpdating = false
|
||||
return c.json({ ok: false, error: 'failed to start update' }, 500)
|
||||
}
|
||||
})
|
||||
|
||||
export default router
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user