ui/server/src/devServer-1
Cockpit server, next. Source: n/a.
Variables#
DEFAULT_KILL_GRACE_MS#
constDEFAULT_KILL_GRACE_MS:4000=4_000
Defined in: ui/server/src/devServer.mjs:45
DEFAULT_PORT_BASE#
constDEFAULT_PORT_BASE:5173=5173
Defined in: ui/server/src/devServer.mjs:39
The port tried first: Vite's default, so a typical app lands where its developer expects.
DEFAULT_STARTUP_TIMEOUT_MS#
constDEFAULT_STARTUP_TIMEOUT_MS:90000=90_000
Defined in: ui/server/src/devServer.mjs:44
REFUSALS#
constREFUSALS:Readonly<{NO_PROJECT: {code:string;message:string; };NO_SCRIPT: {code:string;message:string; };OUTSIDE_WORKSPACE: {code:string;message:string; }; }>
Defined in: ui/server/src/devServer.mjs:49
RESERVED_PORTS#
constRESERVED_PORTS: readonlynumber[]
Defined in: ui/server/src/devServer.mjs:41
Ports the Cockpit will not hand out (its own defaults and the web's), whether or not they look free.
Functions#
busyPortFrom()#
busyPortFrom(
text):number
Defined in: ui/server/src/devServer.mjs:83
The port the output says was taken (EADDRINUSE ... :5173, Port 5173 is in use), or null.
Parameters#
text
any
Returns#
number
createDevServerService()#
createDevServerService(
options?):object
Defined in: ui/server/src/devServer.mjs:193
Parameters#
options?
getBranchInfo?
(root) => object = ...
which branch is checked out, and did Cockpit create it
getProjectDir
() => string
the directory the Cockpit is pointed at right now
killGraceMs?
number = DEFAULT_KILL_GRACE_MS
SIGTERM -> SIGKILL grace on stop
log?
{ record: Function; } = serverLog
where output lines go (the Logs tab); record(source, level, text, now, login)
log.record
Function
portBase?
number = ...
first port tried (default 5173, or CONSTRUCT_DEV_SERVER_PORT_BASE)
spawn?
any = nodeSpawn
test seam
startupTimeoutMs?
number = ...
how long "starting" may last before it is treated as failed
Returns#
start
start: (
__namedParameters) =>Promise<{body: {branch:string;branchKind:string;code:string;command: {display:string;script:string;text:string; };error:any;failure:any;networkWarning:any;ok:boolean;pid:any;port:any;refusal:any;root:any;startedAt:any;state:any;url:any;version:any; };status:number; } | {body: {branch:string;branchKind:string;command: {display:string;script:string;text:string; };failure:any;networkWarning:any;ok:boolean;pid:any;port:any;refusal:any;root:any;startedAt:any;state:any;url:any;version:any; };status:number; }>
Parameters
__namedParameters?
Returns
Promise<{ body: { branch: string; branchKind: string; code: string; command: { display: string; script: string; text: string; }; error: any; failure: any; networkWarning: any; ok: boolean; pid: any; port: any; refusal: any; root: any; startedAt: any; state: any; url: any; version: any; }; status: number; } | { body: { branch: string; branchKind: string; command: { display: string; script: string; text: string; }; failure: any; networkWarning: any; ok: boolean; pid: any; port: any; refusal: any; root: any; startedAt: any; state: any; url: any; version: any; }; status: number; }>
stop
stop: () =>
Promise<{body: {branch:string;branchKind:string;command: {display:string;script:string;text:string; };failure:any;networkWarning:any;ok:boolean;pid:any;port:any;refusal:any;root:any;startedAt:any;state:any;url:any;version:any; };status:number; }>
Returns
Promise<{ body: { branch: string; branchKind: string; command: { display: string; script: string; text: string; }; failure: any; networkWarning: any; ok: boolean; pid: any; port: any; refusal: any; root: any; startedAt: any; state: any; url: any; version: any; }; status: number; }>
currentRoot()
currentRoot():
string
The project root a stop-on-close should target: the one the Cockpit is looking at now, or null.
Returns
string
restart()
restart(
opts?):Promise<{body: {branch:string;branchKind:string;code:string;command: {display:string;script:string;text:string; };error:any;failure:any;networkWarning:any;ok:boolean;pid:any;port:any;refusal:any;root:any;startedAt:any;state:any;url:any;version:any; };status:number; } | {body: {branch:string;branchKind:string;command: {display:string;script:string;text:string; };failure:any;networkWarning:any;ok:boolean;pid:any;port:any;refusal:any;root:any;startedAt:any;state:any;url:any;version:any; };status:number; }>
Parameters
opts?
Returns
Promise<{ body: { branch: string; branchKind: string; code: string; command: { display: string; script: string; text: string; }; error: any; failure: any; networkWarning: any; ok: boolean; pid: any; port: any; refusal: any; root: any; startedAt: any; state: any; url: any; version: any; }; status: number; } | { body: { branch: string; branchKind: string; command: { display: string; script: string; text: string; }; failure: any; networkWarning: any; ok: boolean; pid: any; port: any; refusal: any; root: any; startedAt: any; state: any; url: any; version: any; }; status: number; }>
status()
status():
object
Returns
object
branch
branch:
string
branchKind
branchKind:
string
command
command:
object
command.display
display:
string
command.script
script:
string
command.text
text:
string
failure
failure:
any
networkWarning
networkWarning:
any
ok
ok:
boolean=true
pid
pid:
any
port
port:
any
refusal
refusal:
any
root
root:
any
startedAt
startedAt:
any
state
state:
any
url
url:
any
version
version:
any
stopAll()
stopAll():
Promise<void>
Stop every user's dev server (the Cockpit itself is shutting down, and tests). Never throws.
Returns
Promise<void>
stopForLogin()
stopForLogin(
login):Promise<void>
Stop every dev server one login started (that login signing out); other users' keep running. null/unusable
login stops nothing. '' is the no-session (auth off) user. Never throws.
Parameters
login
any
Returns
Promise<void>
stopForRoot()
stopForRoot(
root):Promise<void>
Stop the dev server of one project (Close project / switching projects). Never throws.
Parameters
root
any
Returns
Promise<void>
findFreePort()#
findFreePort(
from?,__namedParameters?):Promise<number>
Defined in: ui/server/src/devServer.mjs:100
The first free port at or above from, skipping the reserved ones and any in taken (ports another slot has claimed but not bound yet); null when none in the search window.
Parameters#
from?
number = DEFAULT_PORT_BASE
__namedParameters?
reserved?
readonly number[] = RESERVED_PORTS
taken?
any = null
Returns#
Promise<number>
isPortFree()#
isPortFree(
port,host?):Promise<any>
Defined in: ui/server/src/devServer.mjs:90
Can something listen on 127.0.0.1:port right now?
Parameters#
port
any
host?
string = '127.0.0.1'
Returns#
Promise<any>
killLiveDevServers()#
killLiveDevServers():
void
Defined in: ui/server/src/devServer.mjs:156
SIGKILL every live dev server's process group. Registered on exit and the terminating signals; exported for tests.
Returns#
void
looksLikePortBusy()#
looksLikePortBusy(
text):boolean
Defined in: ui/server/src/devServer.mjs:78
Does this output say the port was taken? Covers Node's own EADDRINUSE and the wording Vite/Next/webpack use.
Parameters#
text
any
Returns#
boolean
nonLoopbackAddresses()#
nonLoopbackAddresses():
any[]
Defined in: ui/server/src/devServer.mjs:126
This machine's own addresses other than loopback, on every interface (what a LAN peer could reach it by).
Returns#
any[]
parseLocalPort()#
parseLocalPort(
line):number
Defined in: ui/server/src/devServer.mjs:71
A local address in a line of dev-server output (Local: http://localhost:5173/), as a port, or null.
Parameters#
line
any
Returns#
number
readDevCommand()#
readDevCommand(
root): {display?:undefined;refusal: {code:string;message:string; };script?:undefined;text?:undefined; } | {display:string;refusal?:undefined;script:string;text:string; }
Defined in: ui/server/src/devServer.mjs:56
{script, text, display} for the project at root, or {refusal}. dev wins over start. Reads only.
Parameters#
root
any
Returns#
{ display?: undefined; refusal: { code: string; message: string; }; script?: undefined; text?: undefined; } | { display: string; refusal?: undefined; script: string; text: string; }