dd9d53060b
- package/Makefile + s9pk.mk + package.json + tsconfig.json - startos/manifest: dockerBuild source pointing at ../image/Dockerfile - startos/main: reads /data/config.yaml reactively, passes env vars to container - startos/interfaces: binds port 9999 as HTTP UI - startos/actions: showPublicKey (read /data/ssh/id_ed25519.pub), configureSparks - TS + JS bundle compile clean (tsc --noEmit, ncc build)
51 lines
1.5 KiB
TypeScript
51 lines
1.5 KiB
TypeScript
import { i18n } from './i18n'
|
|
import { sdk } from './sdk'
|
|
import { uiPort } from './utils'
|
|
import { sparkConfigYaml } from './fileModels/sparkConfig.yaml'
|
|
|
|
export const main = sdk.setupMain(async ({ effects }) => {
|
|
console.info(i18n('Starting Spark Control…'))
|
|
|
|
// Reactively read SSH targets from the user-configured yaml file.
|
|
// Changing this file via the "Configure Sparks" action restarts the daemon.
|
|
const cfg = (await sparkConfigYaml.read().const(effects)) ?? {
|
|
spark1_host: '',
|
|
spark1_user: '<spark-user>',
|
|
spark2_host: '',
|
|
spark2_user: '<spark-user>',
|
|
}
|
|
|
|
return sdk.Daemons.of(effects).addDaemon('primary', {
|
|
subcontainer: await sdk.SubContainer.of(
|
|
effects,
|
|
{ imageId: 'spark-control' },
|
|
sdk.Mounts.of().mountVolume({
|
|
volumeId: 'main',
|
|
subpath: null,
|
|
mountpoint: '/data',
|
|
readonly: false,
|
|
}),
|
|
'spark-control-sub',
|
|
),
|
|
exec: {
|
|
command: ['/app/entrypoint.sh'],
|
|
env: {
|
|
SPARK1_HOST: cfg.spark1_host,
|
|
SPARK1_USER: cfg.spark1_user,
|
|
SPARK2_HOST: cfg.spark2_host,
|
|
SPARK2_USER: cfg.spark2_user,
|
|
BIND_PORT: String(uiPort),
|
|
},
|
|
},
|
|
ready: {
|
|
display: i18n('Web Interface'),
|
|
fn: () =>
|
|
sdk.healthCheck.checkPortListening(effects, uiPort, {
|
|
successMessage: i18n('The web interface is ready'),
|
|
errorMessage: i18n('The web interface is not ready'),
|
|
}),
|
|
},
|
|
requires: [],
|
|
})
|
|
})
|