testing/daemon_info.ts

Daemon-info file plumbing for the testing servers — ~/.{name}/run/daemon.json, written at startup and read for stale-process detection.

view source

Declarations
#

6 declarations

DaemonInfo
#

testing/daemon_info.ts view source

value + type

{ version: number; pid: number; port: number; started: string; app_version: string; } import {DaemonInfo} from '@fuzdev/fuz_app/testing/daemon_info.js';

Daemon info schema for ~/.{name}/run/daemon.json, a strict @fuzdev/fuz_schema object schema.

version

type number

pid

type number

port

type number

started

type string

app_version

type string

get_app_dir
#

testing/daemon_info.ts view source

(runtime: Pick<EnvDeps, "env_get">, name: string): string | null import {get_app_dir} from '@fuzdev/fuz_app/testing/daemon_info.js';

Get an app's home directory path (~/.{name}).

runtime

runtime with env_get capability

type Pick<EnvDeps, "env_get">

name

application name (e.g., "tx", "zzz")

type string

returns

string | null

path to the app directory, or null if $HOME is not set

get_daemon_info_path
#

testing/daemon_info.ts view source

(runtime: Pick<EnvDeps, "env_get">, name: string): string | null import {get_daemon_info_path} from '@fuzdev/fuz_app/testing/daemon_info.js';

Get the daemon info file path (~/.{name}/run/daemon.json).

runtime

runtime with env_get capability

type Pick<EnvDeps, "env_get">

name

application name

type string

returns

string | null

path to daemon.json, or null if $HOME is not set

is_daemon_running
#

testing/daemon_info.ts view source

(runtime: CommandDeps, pid: number): Promise<boolean> import {is_daemon_running} from '@fuzdev/fuz_app/testing/daemon_info.js';

Check if a process is running by PID.

runtime

runtime with command execution capability

pid

process ID to check

type number

returns

Promise<boolean>

true if the process is running

read_daemon_info
#

testing/daemon_info.ts view source

(runtime: Pick<EnvDeps, "env_get"> & Pick<FsReadDeps, "stat" | "read_text_file"> & LogDeps, name: string): Promise<{ version: number; pid: number; port: number; started: string; app_version: string; } | null> import {read_daemon_info} from '@fuzdev/fuz_app/testing/daemon_info.js';

Read and validate daemon info from the PID file.

runtime

runtime with file read and env capabilities

type Pick<EnvDeps, "env_get"> & Pick<FsReadDeps, "stat" | "read_text_file"> & LogDeps

name

application name

type string

returns

Promise<DaemonInfo | null>

parsed daemon info, or null if missing or invalid

write_daemon_info
#

testing/daemon_info.ts view source

(runtime: Pick<EnvDeps, "env_get"> & Pick<FsWriteDeps, "mkdir" | "rename" | "write_text_file">, name: string, info: { version: number; pid: number; port: number; started: string; app_version: string; }): Promise<...> import {write_daemon_info} from '@fuzdev/fuz_app/testing/daemon_info.js';

Write daemon info to the PID file, creating directories as needed.

runtime

runtime with file write and env capabilities

type Pick<EnvDeps, "env_get"> & Pick<FsWriteDeps, "mkdir" | "write_text_file" | "rename">

name

application name

type string

info

daemon info to write

returns

Promise<void>

throws

  • Error - if `$HOME` is not set

mutates

  • filesystem — creates `~/.{name}/run/` and atomically writes `daemon.json`

Depends on
#

Imported by
#