Skip to content
4 changes: 3 additions & 1 deletion apps/cli/src/cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import { metrics, query } from "./commands/data"
import { timeseries, breakdown, compare } from "./commands/analytics"
import { login, logout, whoami } from "./commands/auth"
import { use } from "./commands/config"
import { start, stop, reset } from "./commands/server"
import { start, stop, reset, checkpoint, restore } from "./commands/server"
import { update } from "./commands/update"

// One CLI, two backends. Every query command bottoms out at the shared
Expand Down Expand Up @@ -46,6 +46,8 @@ export const cli = Command.make("maple").pipe(
start,
stop,
reset,
checkpoint,
restore,
// Self-update
update,
// Services
Expand Down
28 changes: 28 additions & 0 deletions apps/cli/src/commands/server-args.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
export type DirtyStorePolicy = "wipe" | "fail" | "restore-checkpoint"

export interface DetachedChildArgs {
readonly entry: string | undefined
readonly port: number
readonly dataDir: string
readonly offline: boolean
readonly chdbConfigFile: string | undefined
readonly onDirtyStore: DirtyStorePolicy
}

/** Build the foreground child argv without forwarding compiled-Bun virtual
* entrypoints or the background flag that caused the re-exec. */
export const buildDetachedChildArgs = (options: DetachedChildArgs): string[] => {
const runtimeArgs = options.entry && !options.entry.startsWith("/$bunfs") ? [options.entry] : []
return [
...runtimeArgs,
"start",
"--port",
String(options.port),
"--data-dir",
options.dataDir,
"--on-dirty-store",
options.onDirtyStore,
...(options.chdbConfigFile ? ["--chdb-config-file", options.chdbConfigFile] : []),
...(options.offline ? ["--offline"] : []),
]
}
Loading