fixes leftover container
This commit is contained in:
parent
2fa4ab9b12
commit
6c0038b421
3 changed files with 16 additions and 8 deletions
|
@ -1,11 +1,10 @@
|
||||||
export type { Base, BaseContext } from "./lib/create.ts";
|
export type { Base, BaseContext } from "./lib/create.ts";
|
||||||
|
|
||||||
import { toText } from "https://deno.land/std@0.208.0/streams/to_text.ts";
|
import { toText } from "https://deno.land/std@0.208.0/streams/to_text.ts";
|
||||||
import { lines, log_from, loop_process, run } from "./lib/utils.ts";
|
import { lines, log_from, loop_process, LoopProcess, run } from "./lib/utils.ts";
|
||||||
import { ContainerConfig } from "./lib/config.ts";
|
import { ContainerConfig } from "./lib/config.ts";
|
||||||
import { container_paths } from "./lib/paths.ts";
|
import { container_paths } from "./lib/paths.ts";
|
||||||
import { container_command } from "./lib/nspawn.ts";
|
import { container_command, stop_container } from "./lib/nspawn.ts";
|
||||||
import { LoopProcess } from "./lib/utils.ts";
|
|
||||||
import { NginxController } from "./lib/nginx.ts";
|
import { NginxController } from "./lib/nginx.ts";
|
||||||
|
|
||||||
const log = log_from("lib");
|
const log = log_from("lib");
|
||||||
|
@ -81,8 +80,9 @@ export class Runner {
|
||||||
this.loop = null as LoopProcess | null;
|
this.loop = null as LoopProcess | null;
|
||||||
}
|
}
|
||||||
|
|
||||||
start() {
|
async start() {
|
||||||
this.update_proxies();
|
await stop_container(this.name);
|
||||||
|
await this.update_proxies();
|
||||||
this.start_process();
|
this.start_process();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
import { run } from "./utils.ts";
|
import { exists, run } from "./utils.ts";
|
||||||
import * as path from "https://deno.land/std@0.214.0/path/mod.ts";
|
import * as path from "https://deno.land/std@0.214.0/path/mod.ts";
|
||||||
|
|
||||||
export class NginxController {
|
export class NginxController {
|
||||||
|
@ -24,7 +24,7 @@ server {
|
||||||
const conf_file_path = path.join(conf_dir, domain + ".conf");
|
const conf_file_path = path.join(conf_dir, domain + ".conf");
|
||||||
const enabled_conf_file_path = path.join(this.enabled_conf_dir, domain + ".conf");
|
const enabled_conf_file_path = path.join(this.enabled_conf_dir, domain + ".conf");
|
||||||
await Deno.writeTextFile(conf_file_path, conf_file_content);
|
await Deno.writeTextFile(conf_file_path, conf_file_content);
|
||||||
await Deno.remove(enabled_conf_file_path, { recursive: true });
|
if (await exists(enabled_conf_file_path)) await Deno.remove(enabled_conf_file_path);
|
||||||
await run("ln", "-s", await Deno.realPath(conf_file_path), enabled_conf_file_path);
|
await run("ln", "-s", await Deno.realPath(conf_file_path), enabled_conf_file_path);
|
||||||
await this.reload();
|
await this.reload();
|
||||||
return conf_file_path;
|
return conf_file_path;
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
// wrapper
|
// wrapper
|
||||||
|
|
||||||
import { log_from, sleep } from "./utils.ts";
|
import { log_from, run, sleep } from "./utils.ts";
|
||||||
import { ContainerConfigRedirection } from "./config.ts";
|
import { ContainerConfigRedirection } from "./config.ts";
|
||||||
|
|
||||||
const log = log_from("nspawn");
|
const log = log_from("nspawn");
|
||||||
|
@ -30,6 +30,14 @@ export function container_command(name: string, directory: string, opts?: {
|
||||||
return command;
|
return command;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export async function stop_container(name: string) {
|
||||||
|
try {
|
||||||
|
await run("machinectl", "stop", name);
|
||||||
|
} catch (_) {
|
||||||
|
//
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
export async function get_container_addresses(name: string) {
|
export async function get_container_addresses(name: string) {
|
||||||
const command = new Deno.Command("machinectl", { args: ["status", name], stdout: "piped" });
|
const command = new Deno.Command("machinectl", { args: ["status", name], stdout: "piped" });
|
||||||
while (true) {
|
while (true) {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue