mirror of
https://github.com/Pandipipas/scoreko-electron-dev.git
synced 2026-06-06 05:32:06 +00:00
Add human-style explanatory comments in main runtime flow
This commit is contained in:
@@ -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;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user