dsh 0.2.0-rc.2: in-container update (experimental channel), path-agnostic compose, upstream patches adapted to 0.1.x/0.2.x
This commit is contained in:
commit
e6dcef9bf5
302 files changed
+75178
No files matched your search
@@ -0,0 +1,49 @@
|
||||
#!/usr/bin/env node
|
||||
|
||||
import { LocalApiClient } from '../../modules/updater/lib/client.mjs'
|
||||
import { PlatformPaths } from '../../../platform/lib/paths.mjs'
|
||||
|
||||
const paths = new PlatformPaths(
|
||||
process.env.DSH_PLATFORM_DATA ?? '/data/platform',
|
||||
process.env.DSH_PLATFORM_RUN ?? '/run/dsh-platform',
|
||||
)
|
||||
const launch = new LocalApiClient(paths.proxyLaunchSocket)
|
||||
|
||||
if (process.argv[2] === 'health') {
|
||||
const status = await launch.request('GET', '/v1/status')
|
||||
process.exit(status.componentReady === true ? 0 : 1)
|
||||
}
|
||||
|
||||
const token = process.env.DSH_PROXY_LAUNCH_TOKEN
|
||||
delete process.env.DSH_PROXY_LAUNCH_TOKEN
|
||||
if (typeof token !== 'string' || token.length < 32) throw new Error('Proxy launch token is unavailable')
|
||||
await launch.request('POST', '/v1/start', { token })
|
||||
|
||||
let stopping = false
|
||||
let resolveStop
|
||||
const stopped = new Promise(resolve => { resolveStop = resolve })
|
||||
const stop = () => {
|
||||
if (stopping) return
|
||||
stopping = true
|
||||
void launch.request('POST', '/v1/stop', { token }).catch(() => {}).finally(resolveStop)
|
||||
}
|
||||
process.once('SIGINT', stop)
|
||||
process.once('SIGTERM', stop)
|
||||
|
||||
const poll = setInterval(() => {
|
||||
void launch.request('GET', '/v1/status').then(status => {
|
||||
if (!stopping && status.running !== true) {
|
||||
clearInterval(poll)
|
||||
process.exitCode = 1
|
||||
resolveStop()
|
||||
}
|
||||
}, () => {
|
||||
if (!stopping) {
|
||||
clearInterval(poll)
|
||||
process.exitCode = 1
|
||||
resolveStop()
|
||||
}
|
||||
})
|
||||
}, 500)
|
||||
await stopped
|
||||
clearInterval(poll)
|
||||
Reference in new issue
Block a user