Add human-style explanatory comments in main runtime flow

This commit is contained in:
Pandipipas
2026-02-24 00:52:08 +01:00
parent fddf32905a
commit fd4a599ae0
3 changed files with 9 additions and 0 deletions
+4
View File
@@ -53,6 +53,7 @@ export function createNodecgProcessManager({
let lastStderrLine: string | null = null;
const startNodecgProcess = async (): Promise<ChildProcess> => {
// Fail fast with actionable errors before spawning child processes.
validateNodecgInstall(
nodecgRootPath,
appConfig.bundleName,
@@ -107,6 +108,7 @@ export function createNodecgProcessManager({
};
const waitForNodecgReady = async (startTime: number): Promise<void> => {
// Poll the local NodeCG URL until it answers or we hit the configured timeout.
while (Date.now() - startTime < appConfig.startupTimeoutMs) {
if (!nodecgProcess) {
const exitDetails = lastExit
@@ -140,6 +142,7 @@ export function createNodecgProcessManager({
};
const stopNodecgProcessGracefully = (): Promise<void> => {
// Reuse the same stop promise to avoid sending multiple kill signals during app shutdown.
if (stopNodecgPromise) {
return stopNodecgPromise;
}
@@ -267,6 +270,7 @@ function hasReadWriteAccess(candidatePath: string): boolean {
function probePortAvailable(port: number): Promise<boolean> {
return new Promise((resolve) => {
// A successful TCP connection means some process is already listening on the port.
const socket = net.createConnection({ host: "127.0.0.1", port });
let resolved = false;