feat: fold gateway service commands into gateway
This commit is contained in:
@@ -37,14 +37,14 @@ export async function maybeInstallDaemon(params: {
|
||||
);
|
||||
if (action === "restart") {
|
||||
await withProgress(
|
||||
{ label: "Gateway daemon", indeterminate: true, delayMs: 0 },
|
||||
{ label: "Gateway service", indeterminate: true, delayMs: 0 },
|
||||
async (progress) => {
|
||||
progress.setLabel("Restarting Gateway daemon…");
|
||||
progress.setLabel("Restarting Gateway service…");
|
||||
await service.restart({
|
||||
env: process.env,
|
||||
stdout: process.stdout,
|
||||
});
|
||||
progress.setLabel("Gateway daemon restarted.");
|
||||
progress.setLabel("Gateway service restarted.");
|
||||
},
|
||||
);
|
||||
shouldCheckLinger = true;
|
||||
@@ -53,11 +53,11 @@ export async function maybeInstallDaemon(params: {
|
||||
if (action === "skip") return;
|
||||
if (action === "reinstall") {
|
||||
await withProgress(
|
||||
{ label: "Gateway daemon", indeterminate: true, delayMs: 0 },
|
||||
{ label: "Gateway service", indeterminate: true, delayMs: 0 },
|
||||
async (progress) => {
|
||||
progress.setLabel("Uninstalling Gateway daemon…");
|
||||
progress.setLabel("Uninstalling Gateway service…");
|
||||
await service.uninstall({ env: process.env, stdout: process.stdout });
|
||||
progress.setLabel("Gateway daemon uninstalled.");
|
||||
progress.setLabel("Gateway service uninstalled.");
|
||||
},
|
||||
);
|
||||
}
|
||||
@@ -66,12 +66,12 @@ export async function maybeInstallDaemon(params: {
|
||||
if (shouldInstall) {
|
||||
let installError: string | null = null;
|
||||
await withProgress(
|
||||
{ label: "Gateway daemon", indeterminate: true, delayMs: 0 },
|
||||
{ label: "Gateway service", indeterminate: true, delayMs: 0 },
|
||||
async (progress) => {
|
||||
if (!params.daemonRuntime) {
|
||||
daemonRuntime = guardCancel(
|
||||
await select({
|
||||
message: "Gateway daemon runtime",
|
||||
message: "Gateway service runtime",
|
||||
options: GATEWAY_DAEMON_RUNTIME_OPTIONS,
|
||||
initialValue: DEFAULT_GATEWAY_DAEMON_RUNTIME,
|
||||
}),
|
||||
@@ -79,7 +79,7 @@ export async function maybeInstallDaemon(params: {
|
||||
) as GatewayDaemonRuntime;
|
||||
}
|
||||
|
||||
progress.setLabel("Preparing Gateway daemon…");
|
||||
progress.setLabel("Preparing Gateway service…");
|
||||
|
||||
const { programArguments, workingDirectory, environment } = await buildGatewayInstallPlan({
|
||||
env: process.env,
|
||||
@@ -89,7 +89,7 @@ export async function maybeInstallDaemon(params: {
|
||||
warn: (message, title) => note(message, title),
|
||||
});
|
||||
|
||||
progress.setLabel("Installing Gateway daemon…");
|
||||
progress.setLabel("Installing Gateway service…");
|
||||
try {
|
||||
await service.install({
|
||||
env: process.env,
|
||||
@@ -98,15 +98,15 @@ export async function maybeInstallDaemon(params: {
|
||||
workingDirectory,
|
||||
environment,
|
||||
});
|
||||
progress.setLabel("Gateway daemon installed.");
|
||||
progress.setLabel("Gateway service installed.");
|
||||
} catch (err) {
|
||||
installError = err instanceof Error ? err.message : String(err);
|
||||
progress.setLabel("Gateway daemon install failed.");
|
||||
progress.setLabel("Gateway service install failed.");
|
||||
}
|
||||
},
|
||||
);
|
||||
if (installError) {
|
||||
note("Gateway daemon install failed: " + installError, "Gateway");
|
||||
note("Gateway service install failed: " + installError, "Gateway");
|
||||
note(gatewayInstallErrorHint(), "Gateway");
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -359,7 +359,7 @@ export async function runConfigureWizard(
|
||||
if (!selected.includes("gateway")) {
|
||||
const portInput = guardCancel(
|
||||
await text({
|
||||
message: "Gateway port for daemon install",
|
||||
message: "Gateway port for service install",
|
||||
initialValue: String(gatewayPort),
|
||||
validate: (value) => (Number.isFinite(Number(value)) ? undefined : "Invalid port"),
|
||||
}),
|
||||
@@ -481,7 +481,7 @@ export async function runConfigureWizard(
|
||||
if (!didConfigureGateway) {
|
||||
const portInput = guardCancel(
|
||||
await text({
|
||||
message: "Gateway port for daemon install",
|
||||
message: "Gateway port for service install",
|
||||
initialValue: String(gatewayPort),
|
||||
validate: (value) => (Number.isFinite(Number(value)) ? undefined : "Invalid port"),
|
||||
}),
|
||||
|
||||
@@ -100,6 +100,6 @@ describe("buildGatewayInstallPlan", () => {
|
||||
describe("gatewayInstallErrorHint", () => {
|
||||
it("returns platform-specific hints", () => {
|
||||
expect(gatewayInstallErrorHint("win32")).toContain("Run as administrator");
|
||||
expect(gatewayInstallErrorHint("linux")).toContain("clawdbot daemon install");
|
||||
expect(gatewayInstallErrorHint("linux")).toContain("clawdbot gateway install");
|
||||
});
|
||||
});
|
||||
|
||||
@@ -65,6 +65,6 @@ export async function buildGatewayInstallPlan(params: {
|
||||
|
||||
export function gatewayInstallErrorHint(platform = process.platform): string {
|
||||
return platform === "win32"
|
||||
? "Tip: rerun from an elevated PowerShell (Start → type PowerShell → right-click → Run as administrator) or skip daemon install."
|
||||
: `Tip: rerun \`${formatCliCommand("clawdbot daemon install")}\` after fixing the error.`;
|
||||
? "Tip: rerun from an elevated PowerShell (Start → type PowerShell → right-click → Run as administrator) or skip service install."
|
||||
: `Tip: rerun \`${formatCliCommand("clawdbot gateway install")}\` after fixing the error.`;
|
||||
}
|
||||
|
||||
@@ -70,10 +70,10 @@ export function buildGatewayRuntimeHints(
|
||||
hints.push(
|
||||
`LaunchAgent label cached but plist missing. Clear with: launchctl bootout gui/$UID/${label}`,
|
||||
);
|
||||
hints.push(`Then reinstall: ${formatCliCommand("clawdbot daemon install", env)}`);
|
||||
hints.push(`Then reinstall: ${formatCliCommand("clawdbot gateway install", env)}`);
|
||||
}
|
||||
if (runtime.missingUnit) {
|
||||
hints.push(`Service not installed. Run: ${formatCliCommand("clawdbot daemon install", env)}`);
|
||||
hints.push(`Service not installed. Run: ${formatCliCommand("clawdbot gateway install", env)}`);
|
||||
if (fileLog) hints.push(`File logs: ${fileLog}`);
|
||||
return hints;
|
||||
}
|
||||
|
||||
@@ -139,16 +139,16 @@ export async function maybeRepairGatewayDaemon(params: {
|
||||
return;
|
||||
}
|
||||
}
|
||||
note("Gateway daemon not installed.", "Gateway");
|
||||
note("Gateway service not installed.", "Gateway");
|
||||
if (params.cfg.gateway?.mode !== "remote") {
|
||||
const install = await params.prompter.confirmSkipInNonInteractive({
|
||||
message: "Install gateway daemon now?",
|
||||
message: "Install gateway service now?",
|
||||
initialValue: true,
|
||||
});
|
||||
if (install) {
|
||||
const daemonRuntime = await params.prompter.select<GatewayDaemonRuntime>(
|
||||
{
|
||||
message: "Gateway daemon runtime",
|
||||
message: "Gateway service runtime",
|
||||
options: GATEWAY_DAEMON_RUNTIME_OPTIONS,
|
||||
initialValue: DEFAULT_GATEWAY_DAEMON_RUNTIME,
|
||||
},
|
||||
@@ -171,7 +171,7 @@ export async function maybeRepairGatewayDaemon(params: {
|
||||
environment,
|
||||
});
|
||||
} catch (err) {
|
||||
note(`Gateway daemon install failed: ${String(err)}`, "Gateway");
|
||||
note(`Gateway service install failed: ${String(err)}`, "Gateway");
|
||||
note(gatewayInstallErrorHint(), "Gateway");
|
||||
}
|
||||
}
|
||||
@@ -193,7 +193,7 @@ export async function maybeRepairGatewayDaemon(params: {
|
||||
|
||||
if (serviceRuntime?.status !== "running") {
|
||||
const start = await params.prompter.confirmSkipInNonInteractive({
|
||||
message: "Start gateway daemon now?",
|
||||
message: "Start gateway service now?",
|
||||
initialValue: true,
|
||||
});
|
||||
if (start) {
|
||||
@@ -208,14 +208,14 @@ export async function maybeRepairGatewayDaemon(params: {
|
||||
if (process.platform === "darwin") {
|
||||
const label = resolveGatewayLaunchAgentLabel(process.env.CLAWDBOT_PROFILE);
|
||||
note(
|
||||
`LaunchAgent loaded; stopping requires "${formatCliCommand("clawdbot daemon stop")}" or launchctl bootout gui/$UID/${label}.`,
|
||||
`LaunchAgent loaded; stopping requires "${formatCliCommand("clawdbot gateway stop")}" or launchctl bootout gui/$UID/${label}.`,
|
||||
"Gateway",
|
||||
);
|
||||
}
|
||||
|
||||
if (serviceRuntime?.status === "running") {
|
||||
const restart = await params.prompter.confirmSkipInNonInteractive({
|
||||
message: "Restart gateway daemon now?",
|
||||
message: "Restart gateway service now?",
|
||||
initialValue: true,
|
||||
});
|
||||
if (restart) {
|
||||
|
||||
@@ -97,7 +97,7 @@ export async function maybeMigrateLegacyGatewayService(
|
||||
|
||||
const daemonRuntime = await prompter.select<GatewayDaemonRuntime>(
|
||||
{
|
||||
message: "Gateway daemon runtime",
|
||||
message: "Gateway service runtime",
|
||||
options: GATEWAY_DAEMON_RUNTIME_OPTIONS,
|
||||
initialValue: DEFAULT_GATEWAY_DAEMON_RUNTIME,
|
||||
},
|
||||
@@ -120,7 +120,7 @@ export async function maybeMigrateLegacyGatewayService(
|
||||
environment,
|
||||
});
|
||||
} catch (err) {
|
||||
runtime.error(`Gateway daemon install failed: ${String(err)}`);
|
||||
runtime.error(`Gateway service install failed: ${String(err)}`);
|
||||
note(gatewayInstallErrorHint(), "Gateway");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -21,7 +21,7 @@ export async function installGatewayDaemonNonInteractive(params: {
|
||||
const systemdAvailable =
|
||||
process.platform === "linux" ? await isSystemdUserServiceAvailable() : true;
|
||||
if (process.platform === "linux" && !systemdAvailable) {
|
||||
runtime.log("Systemd user services are unavailable; skipping daemon install.");
|
||||
runtime.log("Systemd user services are unavailable; skipping service install.");
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -48,7 +48,7 @@ export async function installGatewayDaemonNonInteractive(params: {
|
||||
environment,
|
||||
});
|
||||
} catch (err) {
|
||||
runtime.error(`Gateway daemon install failed: ${String(err)}`);
|
||||
runtime.error(`Gateway service install failed: ${String(err)}`);
|
||||
runtime.log(gatewayInstallErrorHint());
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -574,6 +574,6 @@ export async function statusCommand(
|
||||
if (gatewayReachable) {
|
||||
runtime.log(` Need to test channels? ${formatCliCommand("clawdbot status --deep")}`);
|
||||
} else {
|
||||
runtime.log(` Fix reachability first: ${formatCliCommand("clawdbot gateway status")}`);
|
||||
runtime.log(` Fix reachability first: ${formatCliCommand("clawdbot gateway probe")}`);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -51,7 +51,7 @@ function buildScopeSelection(opts: UninstallOptions): {
|
||||
|
||||
async function stopAndUninstallService(runtime: RuntimeEnv): Promise<boolean> {
|
||||
if (isNixMode) {
|
||||
runtime.error("Nix mode detected; daemon uninstall is disabled.");
|
||||
runtime.error("Nix mode detected; service uninstall is disabled.");
|
||||
return false;
|
||||
}
|
||||
const service = resolveGatewayService();
|
||||
|
||||
Reference in New Issue
Block a user