enable nginx config management

This commit is contained in:
JOLIMAITRE Matthieu 2024-02-03 23:15:07 +01:00
parent 686ed543ab
commit 466239d0e6
4 changed files with 55 additions and 20 deletions

View file

@ -2,6 +2,7 @@
import { daemon_listen, Runner } from "./src/lib.ts";
import { ContainerConfig } from "./src/lib/config.ts";
import { NginxController } from "./src/lib/nginx.ts";
import { socket_path, state_path } from "./src/lib/paths.ts";
import { log_from, sleep } from "./src/lib/utils.ts";
@ -78,9 +79,11 @@ async function main() {
class State {
enabled;
nginx;
constructor() {
this.enabled = new Map<string, Runner>();
this.nginx = new NginxController("barnulf.net", "/etc/nginx/sites-enabled");
}
static async load() {
@ -104,7 +107,7 @@ class State {
const config = await ContainerConfig.load(name); // TODO
if (config === null) throw new Error("can't read config");
log("starting container", name);
const runner = new Runner(config);
const runner = new Runner(config, this.nginx);
runner.start();
this.enabled.set(name, runner);
log("container", name, "started");