History

fix supervised and local regressions

Rhys Sullivan committed 5 months ago

Commit 831bfbd1 parent 498e4a614 files · +997 −52Browse files

Showing the changes to apps/cli/src (3 of 14 files). Show all

Unified · Split

3 files
  1. apps/cli/src/daemon.ts +2 −2
  2. apps/cli/src/main.ts +2 −2
  3. apps/cli/src/service.ts +18 −5
apps/cli/src/daemon.ts+2−2
@@ -89,8 +89,8 @@ export const isExecutorServerReachable = ( · 88 unmodified lines
89 // misconfigured base URL can't leak the bearer token to a third-party host.89 // misconfigured base URL can't leak the bearer token to a third-party host.
90 const url = new URL("/api/health", input.baseUrl);90 const url = new URL("/api/health", input.baseUrl);
91 const response = await fetch(url, { signal: AbortSignal.timeout(2000) });91 const response = await fetch(url, { signal: AbortSignal.timeout(2000) });
92 await response.body?.cancel();92 const body = await response.text();
93 return response.ok;93 return response.ok && body.trim() === "ok";
94 }).pipe(Effect.catchCause(() => Effect.succeed(false)));94 }).pipe(Effect.catchCause(() => Effect.succeed(false)));
95 95
96// ---------------------------------------------------------------------------96// ---------------------------------------------------------------------------
apps/cli/src/main.ts+2−2
@@ -2270,8 +2270,8 @@ const openInBrowser = (url: string): Effect.Effect<void> => · 2269 unmodified lines
2270 */2270 */
2271const openCommand = Command.make("open", {}, () =>2271const openCommand = Command.make("open", {}, () =>
2272 Effect.gen(function* () {2272 Effect.gen(function* () {
2273 const manifest = yield* readLocalServerManifest();2273 const manifest = yield* readActiveLocalServerManifest().pipe(Effect.orElseSucceed(() => null));
2274 if (!manifest || !isPidAlive(manifest.pid)) {2274 if (!manifest) {
2275 console.log("No local Executor server is running.");2275 console.log("No local Executor server is running.");
2276 console.log(`Start one with: ${cliPrefix} web`);2276 console.log(`Start one with: ${cliPrefix} web`);
2277 return;2277 return;
apps/cli/src/service.ts+18−5
@@ -340,11 +340,24 @@ export interface SystemdUnitOptions { · 339 unmodified lines
340 readonly stderrPath: string;340 readonly stderrPath: string;
341}341}
342 342
343const SYSTEMD_BARE_VALUE = /^[A-Za-z0-9_@%+=:,./-]+$/;
344
345const systemdQuote = (value: string): string => {
346 if (SYSTEMD_BARE_VALUE.test(value)) return value;
347 const escaped = value
348 .replaceAll("\\", "\\\\")
349 .replaceAll('"', '\\"')
350 .replaceAll("\n", "\\n")
351 .replaceAll("\r", "\\r")
352 .replaceAll("\t", "\\t");
353 return `"${escaped}"`;
354};
355
343/** Render a systemd --user unit. Pure (snapshot-tested). */356/** Render a systemd --user unit. Pure (snapshot-tested). */
344export const generateSystemdUnit = (options: SystemdUnitOptions): string => {357export const generateSystemdUnit = (options: SystemdUnitOptions): string => {
345 const execStart = options.execStart.map((arg) => (/\s/.test(arg) ? `"${arg}"` : arg)).join(" ");358 const execStart = options.execStart.map(systemdQuote).join(" ");
346 const env = Object.entries(options.environment)359 const env = Object.entries(options.environment)
347 .map(([key, value]) => `Environment=${key}=${value}`)360 .map(([key, value]) => `Environment=${systemdQuote(`${key}=${value}`)}`)
348 .join("\n");361 .join("\n");
349 return `[Unit]362 return `[Unit]
350Description=Executor supervised daemon363Description=Executor supervised daemon
@@ -354,9 +367,9 @@ After=default.target · 3 unmodified lines
354Type=simple367Type=simple
355ExecStart=${execStart}368ExecStart=${execStart}
356${env}369${env}
357WorkingDirectory=${options.workingDirectory}370WorkingDirectory=${systemdQuote(options.workingDirectory)}
358StandardOutput=append:${options.stdoutPath}371StandardOutput=${systemdQuote(`append:${options.stdoutPath}`)}
359StandardError=append:${options.stderrPath}372StandardError=${systemdQuote(`append:${options.stderrPath}`)}
360Restart=on-failure373Restart=on-failure
361RestartSec=5s374RestartSec=5s
362 375

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t