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,38 @@
|
||||
#!/usr/bin/env node
|
||||
|
||||
import { loadConfig } from './lib/config.mjs'
|
||||
import { UsageError } from './lib/errors.mjs'
|
||||
import { runGateway } from './lib/lifecycle.mjs'
|
||||
import { JsonlLogManager } from '../../modules/log-manager/index.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 logs = new JsonlLogManager({
|
||||
root: paths.logsRoot,
|
||||
maxBytes: Number(process.env.DSH_LOG_MAX_BYTES ?? 104857600),
|
||||
retentionDays: Number(process.env.DSH_LOG_RETENTION_DAYS ?? 14),
|
||||
output: { stdout: process.stdout, stderr: process.stderr },
|
||||
})
|
||||
logs.on('error', error => { void logs.diagnostic('log-manager', 'capture.failed', { error }) })
|
||||
const report = (message, fields = {}) => message === 'gateway.access.login-failed'
|
||||
? logs.diagnosticRateLimited(
|
||||
`gateway.access.login-failed:${typeof fields.code === 'string' ? fields.code.toLowerCase() : 'unknown'}`,
|
||||
'gateway', message, fields,
|
||||
)
|
||||
: logs.diagnostic('gateway', message, fields)
|
||||
|
||||
try {
|
||||
const config = await loadConfig()
|
||||
process.exitCode = await runGateway(config, { report, managementPort: config.managementPort })
|
||||
} catch (error) {
|
||||
if (error instanceof UsageError) {
|
||||
await logs.diagnostic('gateway', 'gateway.configuration.failed', { error, level: 'warning' })
|
||||
process.exitCode = error.exitCode
|
||||
} else {
|
||||
await logs.diagnostic('gateway', 'gateway.process.failed', { error })
|
||||
process.exitCode = 1
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user