feat: add make start-debug
This commit is contained in:
@@ -127,12 +127,16 @@ start:
|
||||
@$(MAKE) -s build-web-quiet
|
||||
$(call success,Build complete)
|
||||
$(call phase,Starting Server)
|
||||
@cd $(APPS_DIR) && $(PNPM) -C cli dev -- start $(if $(filter 1 true yes,$(VERBOSE)),--verbose,)
|
||||
@cd $(APPS_DIR) && $(PNPM) -C cli dev -- start $(if $(filter 1 true yes,$(VERBOSE)),--verbose,) $(if $(filter 1 true yes,$(DEBUG)),--debug,)
|
||||
|
||||
.PHONY: start-verbose
|
||||
start-verbose:
|
||||
@$(MAKE) start VERBOSE=1
|
||||
|
||||
.PHONY: start-debug
|
||||
start-debug:
|
||||
@$(MAKE) start DEBUG=1
|
||||
|
||||
.PHONY: build-backend
|
||||
build-backend:
|
||||
@printf "$(CYAN)Building backend...$(RESET)\n"
|
||||
|
||||
+8
-2
@@ -16,6 +16,7 @@ type CliOptions = {
|
||||
backendPort?: number;
|
||||
webPort?: number;
|
||||
verbose?: boolean;
|
||||
debug?: boolean;
|
||||
};
|
||||
|
||||
function printHelp() {
|
||||
@@ -24,7 +25,7 @@ function printHelp() {
|
||||
Usage:
|
||||
kandev run [--version <tag>] [--backend-port <port>] [--web-port <port>]
|
||||
kandev dev [--backend-port <port>] [--web-port <port>]
|
||||
kandev start [--backend-port <port>] [--web-port <port>] [--verbose]
|
||||
kandev start [--backend-port <port>] [--web-port <port>] [--verbose] [--debug]
|
||||
kandev [--version <tag>] [--backend-port <port>] [--web-port <port>]
|
||||
kandev --dev [--backend-port <port>] [--web-port <port>]
|
||||
|
||||
@@ -46,6 +47,7 @@ Options:
|
||||
--backend-port Override backend port.
|
||||
--web-port Override web port.
|
||||
--verbose, -v Show info logs from backend + web (start mode only).
|
||||
--debug Show debug logs + agent message dumps (start mode only).
|
||||
--help, -h Show help.
|
||||
`);
|
||||
}
|
||||
@@ -97,6 +99,10 @@ function parseArgs(argv: string[]): CliOptions {
|
||||
opts.verbose = true;
|
||||
continue;
|
||||
}
|
||||
if (arg === "--debug") {
|
||||
opts.debug = true;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
return opts;
|
||||
}
|
||||
@@ -143,7 +149,7 @@ async function main(): Promise<void> {
|
||||
if (!repoRoot) {
|
||||
throw new Error("Unable to locate repo root for start. Run from the repo.");
|
||||
}
|
||||
await runStart({ repoRoot, backendPort, webPort, verbose: raw.verbose });
|
||||
await runStart({ repoRoot, backendPort, webPort, verbose: raw.verbose, debug: raw.debug });
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
+14
-7
@@ -36,6 +36,8 @@ export type StartOptions = {
|
||||
webPort?: number;
|
||||
/** Show info logs from backend + web */
|
||||
verbose?: boolean;
|
||||
/** Show debug logs + agent message dumps */
|
||||
debug?: boolean;
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -56,6 +58,7 @@ export async function runStart({
|
||||
backendPort,
|
||||
webPort,
|
||||
verbose = false,
|
||||
debug = false,
|
||||
}: StartOptions): Promise<void> {
|
||||
const ports = await pickPorts(backendPort, webPort);
|
||||
|
||||
@@ -83,28 +86,32 @@ export async function runStart({
|
||||
}
|
||||
}
|
||||
|
||||
// Production mode: use warn log level for clean output unless verbose
|
||||
// Production mode: use warn log level for clean output unless verbose/debug
|
||||
const showOutput = verbose || debug;
|
||||
const dbPath = path.join(DATA_DIR, "kandev.db");
|
||||
const backendEnv = buildBackendEnv({
|
||||
ports,
|
||||
logLevel: verbose ? "info" : "warn",
|
||||
extra: { KANDEV_DB_PATH: dbPath },
|
||||
logLevel: debug ? "debug" : verbose ? "info" : "warn",
|
||||
extra: {
|
||||
KANDEV_DB_PATH: dbPath,
|
||||
...(debug ? { KANDEV_DEBUG_AGENT_MESSAGES: "true" } : {}),
|
||||
},
|
||||
});
|
||||
const webEnv = buildWebEnv({ ports, includeMcp: true, production: true });
|
||||
|
||||
const supervisor = createProcessSupervisor();
|
||||
supervisor.attachSignalHandlers();
|
||||
|
||||
// Start backend with piped stdio (quiet mode unless verbose)
|
||||
// Start backend with piped stdio (quiet mode unless verbose/debug)
|
||||
const backendProc = spawn(backendBin, [], {
|
||||
cwd: path.dirname(backendBin),
|
||||
env: backendEnv,
|
||||
stdio: verbose ? ["ignore", "inherit", "inherit"] : ["ignore", "pipe", "pipe"],
|
||||
stdio: showOutput ? ["ignore", "inherit", "inherit"] : ["ignore", "pipe", "pipe"],
|
||||
});
|
||||
supervisor.children.push(backendProc);
|
||||
|
||||
// Forward stderr only (warnings/errors) when quiet
|
||||
if (!verbose) {
|
||||
if (!showOutput) {
|
||||
backendProc.stderr?.pipe(process.stderr);
|
||||
}
|
||||
|
||||
@@ -120,7 +127,7 @@ export async function runStart({
|
||||
url: webUrl,
|
||||
supervisor,
|
||||
label: "web",
|
||||
quiet: !verbose,
|
||||
quiet: !showOutput,
|
||||
});
|
||||
|
||||
const healthTimeoutMs = resolveHealthTimeoutMs(HEALTH_TIMEOUT_MS_RELEASE);
|
||||
|
||||
+1
-1
@@ -105,7 +105,7 @@ export function CommandPreviewCard({
|
||||
{!loading && !error && preview && (
|
||||
<>
|
||||
<div className="relative">
|
||||
<pre className="overflow-x-auto rounded-md bg-muted p-4 font-mono text-xs">
|
||||
<pre className="overflow-x-auto rounded-md bg-muted p-4 pr-12 font-mono text-xs">
|
||||
<code className="whitespace-pre-wrap break-all">{preview.command_string}</code>
|
||||
</pre>
|
||||
<Button
|
||||
|
||||
Reference in New Issue
Block a user