cleanup
This commit is contained in:
parent
b1ee328238
commit
6a77e1294e
2 changed files with 5 additions and 64 deletions
|
@ -1,11 +1,10 @@
|
|||
export type { Base, BaseContext } from "./lib/create.ts";
|
||||
|
||||
import { toText } from "https://deno.land/std@0.208.0/streams/to_text.ts";
|
||||
import { lines, log_from, loop_process, LoopProcess, run, sleep } from "./lib/utils.ts";
|
||||
import { lines, log_from, loop_process, run } from "./lib/utils.ts";
|
||||
import { ContainerConfig } from "./lib/config.ts";
|
||||
import { container_paths } from "./lib/paths.ts";
|
||||
import { container_command, get_container_addresses } from "./lib/nspawn.ts";
|
||||
import { proxy_command } from "./bin/proxy.ts";
|
||||
import { container_command } from "./lib/nspawn.ts";
|
||||
|
||||
const log = log_from("lib");
|
||||
|
||||
|
@ -80,40 +79,14 @@ export function start_runner(config: ContainerConfig) {
|
|||
stdout: "null",
|
||||
},
|
||||
});
|
||||
// const proxies = [] as LoopProcess[];
|
||||
const container_loop = loop_process(command, {
|
||||
on_start: () => {
|
||||
log("container", name, "started");
|
||||
// (async () => {
|
||||
// await sleep(1_000);
|
||||
// const [address] = await get_container_addresses(name);
|
||||
// proxies.push(...start_proxies(address, config.redirects));
|
||||
// })();
|
||||
},
|
||||
on_stop: async () => {
|
||||
log("container", name, "stopped");
|
||||
// for (const p of proxies) await p.kill();
|
||||
// await sleep(500);
|
||||
// proxies.splice(0, proxies.length);
|
||||
},
|
||||
on_start: () => log("container", name, "started"),
|
||||
on_stop: () => log("container", name, "stopped"),
|
||||
});
|
||||
return {
|
||||
name,
|
||||
config,
|
||||
container_loop,
|
||||
stop: async () => {
|
||||
// for (const p of proxies) await p.kill();
|
||||
await container_loop.kill();
|
||||
},
|
||||
stop: () => container_loop.kill(),
|
||||
};
|
||||
}
|
||||
|
||||
function start_proxies(address: string, redirects: [number, number][]) {
|
||||
const redirections = redirects
|
||||
.map(([from_port, to_port]) => {
|
||||
return loop_process(proxy_command(from_port, address, to_port), {
|
||||
on_start: () => console.log("starting proxy", from_port, "to", address, "port", to_port),
|
||||
});
|
||||
});
|
||||
return redirections;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue