add nginx wrapper and refactor

This commit is contained in:
JOLIMAITRE Matthieu 2024-02-03 20:15:35 +01:00
parent 9216063aa0
commit 6f92727bb3
9 changed files with 530 additions and 92 deletions

View file

@ -1,7 +1,7 @@
#!/bin/env -S deno run -A --unstable
import { daemon_listen, Runner, start_runner } from "./src/lib.ts";
import { load_container_config } from "./src/lib/config.ts";
import { daemon_listen, Runner } from "./src/lib.ts";
import { ContainerConfig } from "./src/lib/config.ts";
import { socket_path, state_path } from "./src/lib/paths.ts";
import { log_from, sleep } from "./src/lib/utils.ts";
@ -93,10 +93,12 @@ async function create_state() {
async enable(name: string) {
if (self.enabled.has(name)) throw new Error("Container already enabled");
log("loading container", name);
const config = await load_container_config(name); // TODO
const config = await ContainerConfig.load(name); // TODO
if (config === null) throw new Error("can't read config");
log("starting container", name);
self.enabled.set(name, await start_runner(config));
const runner = new Runner(config);
runner.start();
self.enabled.set(name, runner);
log("container", name, "started");
},
async disable(name: string) {