API reference / @jsprismarine/prismarine / RemoteConsole
Class: RemoteConsole
Defined in: prismarine/src/console/RemoteConsole.ts:48
The server end of the remote console: the service a headless server runs when a host process owns the terminal.
It speaks the console protocol over the link it is given. Log records travel through the RemoteLogTransport the caller already handed to the logger; this class drives the rest: hello and lifecycle on the way up, status once a second while something changed, command and complete round trips, the subscribe level, and a graceful server.shutdown() when the host asks for one or disappears. Chat reaches the log here too, as the line console would have done, so a headless server still records it.
The server calls enable at the start of bootstrap, markRunning once it listens, markStopping when shutdown begins, and disable right before the process exits, so the last messages get out of the IPC channel first.
Implements
Constructors
Constructor
new RemoteConsole(
server,link,transport,options?):RemoteConsole
Defined in: prismarine/src/console/RemoteConsole.ts:68
Parameters
server
The server this console speaks for.
link
FlushableLink<ConsoleMessage, ServerMessage>
The server end of the console link.
transport
The log transport the logger already writes to; subscribe sets its level.
options?
RemoteConsoleOptions = {}
Returns
RemoteConsole
Methods
markRunning()
markRunning():
void
Defined in: prismarine/src/console/RemoteConsole.ts:114
Reports lifecycle running. The server calls it once it listens on its port.
Returns
void
markStopping()
markStopping():
void
Defined in: prismarine/src/console/RemoteConsole.ts:119
Reports lifecycle stopping. The server calls it as shutdown begins; repeats are ignored.
Returns
void
Lifecycle
disable()
disable():
Promise<void>
Defined in: prismarine/src/console/RemoteConsole.ts:136
Answers every command still running with ok: true, sends lifecycle stopping if it has not gone out yet, closes the log transport, and waits up to flushTimeoutMs for the link to drain, so a process.exit that follows does not discard the queued messages. Links without flush return at once.
A command whose dispatch is still pending here is one that stopped the server, such as stop: its await server.shutdown() never settles because shutdown exits the process. Answering it now is the only way the host sees a result instead of a closed link.
Returns
Promise<void>
Implementation of
enable()
enable():
Promise<void>
Defined in: prismarine/src/console/RemoteConsole.ts:89
Sends hello and lifecycle starting, starts answering the host, and begins the status ticker. Calling it again does nothing.
Returns
Promise<void>