mirror of
https://github.com/pockethost/pockethost.git
synced 2025-07-05 04:12:29 +00:00
Add upgrade mode support
This commit is contained in:
parent
cd49c81fd4
commit
da8831a9f7
@ -30,6 +30,8 @@ export const _IS_DEV = process.env.NODE_ENV === 'development'
|
||||
console.log({ _PH_HOME, _PH_PROJECT_ROOT, _PH_BUILD_ROOT })
|
||||
|
||||
export const SETTINGS = {
|
||||
UPGRADE_MODE: mkBoolean(false),
|
||||
|
||||
PH_HOME: mkPath(_PH_HOME),
|
||||
PH_PROJECT_ROOT: mkPath(_PH_PROJECT_ROOT),
|
||||
PH_BUILD_ROOT: mkPath(_PH_BUILD_ROOT, { required: false }),
|
||||
@ -158,6 +160,8 @@ export const instanceLogger = () => ioc.service('instanceLogger')
|
||||
/**
|
||||
* Accessors
|
||||
*/
|
||||
export const UPGRADE_MODE = () => settings().UPGRADE_MODE
|
||||
|
||||
export const PH_HOME = () => settings().PH_HOME
|
||||
export const PH_PROJECT_ROOT = () => settings().PH_PROJECT_ROOT
|
||||
export const PH_BUILD_ROOT = () => settings().PH_BUILD_ROOT
|
||||
|
@ -4,6 +4,7 @@ import {
|
||||
INSTANCE_APP_HOOK_DIR,
|
||||
INSTANCE_APP_MIGRATIONS_DIR,
|
||||
INSTANCE_DATA_DB,
|
||||
UPGRADE_MODE,
|
||||
mkAppUrl,
|
||||
mkContainerHomePath,
|
||||
mkDocUrl,
|
||||
@ -305,6 +306,11 @@ export const instanceService = mkSingleton(
|
||||
return cp
|
||||
} catch (e) {
|
||||
warn(`Error spawning: ${e}`)
|
||||
if (UPGRADE_MODE()) {
|
||||
throw new Error(
|
||||
`PocketHost is rebooting. Try again in a few seconds.`,
|
||||
)
|
||||
} else {
|
||||
await updateInstance(instance.id, {
|
||||
maintenance: true,
|
||||
})
|
||||
@ -313,6 +319,7 @@ export const instanceService = mkSingleton(
|
||||
)
|
||||
throw new Error(`Maintenance mode`)
|
||||
}
|
||||
}
|
||||
})()
|
||||
const { pid: _pid, exitCode } = childProcess
|
||||
const pid = _pid()
|
||||
|
Loading…
x
Reference in New Issue
Block a user