MVP version

This commit is contained in:
Shinuwa 2026-06-12 14:34:44 +02:00
commit 3f96943858
25 changed files with 3962 additions and 0 deletions

View file

@ -0,0 +1,48 @@
import { execFile } from "node:child_process";
import { promisify } from "node:util";
const execFileAsync = promisify(execFile);
async function launchServer(server) {
const profile = getStartProfile(server);
if (!profile) {
const error = new Error("Aucun profil de lancement configure");
error.code = "MISSING_START_PROFILE";
throw error;
}
if (profile === "TEST") {
return execFileAsync("/bin/echo", ["Mock start test server"], {
timeout: 60_000,
maxBuffer: 1024 * 1024,
});
}
const target = process.env[`${profile}_SSH_TARGET`];
const port = process.env[`${profile}_SSH_PORT`];
const command = process.env[`${profile}_START_COMMAND`];
if (!target || !command) {
const error = new Error(`Profil de lancement incomplet: ${profile}`);
error.code = "INCOMPLETE_START_PROFILE";
throw error;
}
const args = [];
if (port) {
args.push("-p", port);
}
args.push(target, command);
return execFileAsync("ssh", args, {
timeout: 60_000,
maxBuffer: 1024 * 1024,
});
}
function getStartProfile(server) {
if (server.startProfile) return server.startProfile;
return "";
}
export { getStartProfile, launchServer };