Add the VardKey daemon definition

This commit is contained in:
ai-bot committed 2026-10-11 10:44:30 +00:00
1 parent 94569c928c
commit 6a688d6d06
1 file changed
+62
+62
View File
@@ -0,0 +1,62 @@
import { i18n } from './i18n'
import { sdk } from './sdk'
import {
dataMountpoint,
databasePath,
imageId,
subcontainerName,
uiPort,
volumeId,
} from './utils'
export const main = sdk.setupMain(async ({ effects }) => {
/**
* ======================== Setup (optional) ========================
*
* Fetch any resources or run any preliminary commands here.
*/
console.info(i18n('Starting VardKey'))
/**
* ======================== Daemons ========================
*
* VardKey is a single daemon: one container, one process, and one SQLite
* database on the persistent "main" volume.
*/
return sdk.Daemons.of(effects).addDaemon('primary', {
subcontainer: sdk.SubContainer.of(
effects,
{ imageId },
sdk.Mounts.of().mountVolume({
volumeId,
subpath: null,
mountpoint: dataMountpoint,
readonly: false,
}),
subcontainerName,
),
exec: {
command: ['python3', 'app.py'],
env: {
PORT: String(uiPort),
DATABASE_PATH: databasePath,
},
},
ready: {
display: i18n('Web Interface'),
// checkWebUrl against the app's own /health endpoint. The port here must
// match uiPort and the port bound in interfaces.ts, or the check never
// goes green.
fn: () =>
sdk.healthCheck.checkWebUrl(
effects,
`http://127.0.0.1:${uiPort}/health`,
{
successMessage: i18n('The web interface is ready'),
errorMessage: i18n('The web interface is not ready'),
},
),
},
requires: [],
})
})