From 86cfc2b390608c3fd96c7711655040a283e83517 Mon Sep 17 00:00:00 2001 From: Tsiry Sandratraina Date: Sat, 27 Jul 2024 17:28:07 +0000 Subject: [PATCH] fix(agent): handle long socket file path fix(agent): handle long socket file path fix(agent): handle long socket file path --- src/utils.ts | 29 +++++++++++++++++++++++++++-- 1 file changed, 27 insertions(+), 2 deletions(-) diff --git a/src/utils.ts b/src/utils.ts index b0a60be..5ef1ffd 100644 --- a/src/utils.ts +++ b/src/utils.ts @@ -1,3 +1,4 @@ +import { createId } from "../deps.ts"; import { dir, brightGreen, wait, green, procfile } from "../deps.ts"; export async function isLogged(): Promise { @@ -478,6 +479,18 @@ export async function stopServices(cwd: string) { const services = []; // deno-lint-ignore no-explicit-any let infos: Record = {}; + const id = createId(); + + if (cwd.length > 64) { + const ln = new Deno.Command("bash", { + args: ["-c", `ln -s ${cwd} $HOME/${id}`], + stdout: "inherit", + stderr: "inherit", + }).spawn(); + await ln.status; + } + + const home = Deno.env.get("HOME")!; for (const file of files) { const manifest = procfile.parse(Deno.readTextFileSync(cwd + "/" + file)); @@ -491,15 +504,27 @@ export async function stopServices(cwd: string) { const socket = file.replace("Procfile", ".overmind.sock"); try { - await writeToSocket(cwd + "/" + socket, "stop\n"); + await writeToSocket( + (cwd.length > 64 ? `${home}/${id}` : cwd) + "/" + socket, + "stop\n" + ); } catch (e) { console.log(`Failed to stop ${green(service)}`); console.log(e); - console.log(cwd, socket); + console.log((cwd.length > 64 ? `${home}/${id}` : cwd) + "/" + socket); continue; } console.log(`Successfully stopped ${green(service)}`); } } + + if (cwd.length > 64) { + const rm = new Deno.Command("bash", { + args: ["-c", `rm $HOME/${id}`], + stdout: "inherit", + stderr: "inherit", + }).spawn(); + await rm.status; + } }