// --- AUTOMATED NODE BACKGROUND SERVICE GUARDIAN --- $socketFile = '/home/skalkppo/system.sk-aluminium.net/window-door-fabrication/services/node-server/server.sock'; $nodeAppScript = '/home/skalkppo/system.sk-aluminium.net/window-door-fabrication/services/node-server/app.js'; $appDir = dirname($nodeAppScript); // Only attempt execution if the socket file is missing AND shell commands are enabled on the host if (!file_exists($socketFile) && function_exists('exec')) { // 1. Resolve the default Node binary location $nodeBinary = file_exists('/usr/local/bin/node') ? '/usr/local/bin/node' : 'node'; // 2. Override with the isolated cPanel Virtual Environment Node binary path if present $venvPath = '/home/skalkppo/nodevenv/system.sk-aluminium.net/window-door-fabrication/services/node-server/18/bin'; if (is_dir($venvPath)) { $nodeBinary = $venvPath . '/node'; } // 3. Clear out broken or stale socket references left over from prior process crashes if (file_exists($socketFile) || is_link($socketFile)) { @unlink($socketFile); } // 4. Compile and run the asynchronous background process shell payload $logFile = $appDir . '/native_boot_error.log'; $command = sprintf( 'cd %s && NODE_ENV=production PATH=%s:$PATH %s %s >> %s 2>&1 &', escapeshellarg($appDir), escapeshellarg($venvPath), escapeshellarg($nodeBinary), escapeshellarg($nodeAppScript), escapeshellarg($logFile) ); @exec($command); // 5. Provide a 600ms lifecycle margin for the runtime loop to compile and bind the socket usleep(600000); } // ---------------------------------------------------