// Set up and run the daemon try { $oDaemon = NULL; // Initialize daemon class $nUIDToRunUnder = NULL; // Don't try to change UID $sPIDFilename = DAEMON_NAME . '.pid'; // PID file simply in current dir $oDaemon = new FileParser($nUIDToRunUnder, $sPIDFilename); // Now set some daemon options $oDaemon->setMaxChildren(2); // Only up to 2 child processes $oDaemon->setSendChildrenUNIXSignals(FALSE); // Don't forward signals $oDaemon->setIdleSleepTime(5 * 1000000); // Wait 5sec when no job avail. printf("Will run %d child process with PID file %s\n", $oDaemon->getMaxChildren(), $oDaemon->getPIDFile()); // Call our own custom init method $oDaemon->demoAppInit(); // Start daemon $oDaemon->daemonRun(); } catch (Exception $e) { if ($oDaemon == NULL) { $sErr = ': Daemon class failed to instantiate: '; } else { $sErr = ': Daemon died: '; } Logger::getInstance()->crit(DAEMON_NAME . $sErr . $e->getMessage()); die($sErr . "\n"); } exit(0);