protected function validate_workers() {

        $this->load_workers();

        if (empty($this->functions)) {
            $this->log("No workers found");
            posix_kill($this->parent_pid, SIGUSR1);
            exit();
        }

        $this->validate_lib_workers();

        /**
         * Since we got here, all must be ok, send a CONTINUE
         */
        $this->log("Helper is running. Sending continue to $this->parent_pid.", GearmanManager::LOG_LEVEL_DEBUG);
        posix_kill($this->parent_pid, SIGCONT);

        if ($this->check_code) {
            $this->log("Running loop to check for new code", self::LOG_LEVEL_DEBUG);
            $last_check_time = 0;
            while (1) {
                $max_time = 0;
                foreach ($this->functions as $name => $func) {
                    clearstatcache();
                    $mtime = filemtime($func['path']);
                    $max_time = max($max_time, $mtime);
                    $this->log("{$func['path']} - $mtime $last_check_time", self::LOG_LEVEL_CRAZY);
                    if ($last_check_time!=0 && $mtime > $last_check_time) {
                        $this->log("New code found. Sending SIGHUP", self::LOG_LEVEL_PROC_INFO);
                        posix_kill($this->parent_pid, SIGHUP);
                        break;
                    }
                }
                $last_check_time = $max_time;
                sleep(5);
            }
        } else {
            exit();
        }

    }
protected function validate_workers() {

        $this->load_workers();

        if (empty($this->functions)) {
            $this->log("No workers found");
            posix_kill($this->parent_pid, SIGUSR1);
            exit();
        }

        $this->validate_lib_workers();

        /**
         * Since we got here, all must be ok, send a CONTINUE
         */
        $this->log("Helper is running. Sending continue to $this->parent_pid.", GearmanManager::LOG_LEVEL_DEBUG);
        posix_kill($this->parent_pid, SIGCONT);

        if ($this->check_code) {
            $this->log("Running loop to check for new code", self::LOG_LEVEL_DEBUG);
            $last_check_time = 0;
            while (1) {
                $max_time = 0;
                foreach ($this->functions as $name => $func) {
                    clearstatcache();
                    $mtime = filemtime($func['path']);
                    $max_time = max($max_time, $mtime);
                    $this->log("{$func['path']} - $mtime $last_check_time", self::LOG_LEVEL_CRAZY);
                    if ($last_check_time!=0 && $mtime > $last_check_time) {
                        $this->log("New code found. Sending SIGHUP", self::LOG_LEVEL_PROC_INFO);
                        posix_kill($this->parent_pid, SIGHUP);
                        break;
                    }
                }
                $last_check_time = $max_time;
                sleep(5);
            }
        } else {
            exit();
        }

    }
protected function validate_workers ( ) { $ this -> load_workers ( ) ; if ( empty ( $ this -> functions ) ) { $ this -> log ( "No workers found" ) ; posix_kill ( $ this -> parent_pid , SIGUSR1 ) ; exit ( ) ; } $ this -> validate_lib_workers ( ) ; /**
         * Since we got here, all must be ok, send a CONTINUE
         */ $ this -> log ( "Helper is running. Sending continue to $this->parent_pid." , GearmanManager :: LOG_LEVEL_DEBUG ) ; posix_kill ( $ this -> parent_pid , SIGCONT ) ; if ( $ this -> check_code ) { $ this -> log ( "Running loop to check for new code" , self :: LOG_LEVEL_DEBUG ) ; $ last_check_time = 0 ; while ( 1 ) { $ max_time = 0 ; foreach ( $ this -> functions as $ name => $ func ) { clearstatcache ( ) ; $ mtime = filemtime ( $ func [ 'path' ] ) ; $ max_time = max ( $ max_time , $ mtime ) ; $ this -> log ( "{$func['path']} - $mtime $last_check_time" , self :: LOG_LEVEL_CRAZY ) ; if ( $ last_check_time != 0 && $ mtime > $ last_check_time ) { $ this -> log ( "New code found. Sending SIGHUP" , self :: LOG_LEVEL_PROC_INFO ) ; posix_kill ( $ this -> parent_pid , SIGHUP ) ; break ; } } $ last_check_time = $ max_time ; sleep ( 5 ) ; } } else { exit ( ) ; } }
Forked method that validates the worker code and checks it if desired
Forked method that validates the worker code and checks it if desired