Resume workers

@return  void
482754
public function resume()
    {
        $ResqueStatus = $this->ResqueStatus;

        $this->debug('Searching for paused workers');
        $options = new SendSignalCommandOptions();
        $options->title = 'Resuming workers';
        $options->noWorkersMessage = 'There is no paused workers to resume';
        $options->allOption = 'Resume all workers';
        $options->selectMessage = 'Worker to resume';
        $options->actionMessage = 'resuming';
        $options->workers = call_user_func(array($this->ResqueStatus, 'getPausedWorker'));
        $options->signal = 'CONT';
        $options->successCallback = function ($pid, $workerName) use ($ResqueStatus) {
            $ResqueStatus->setPausedWorker($workerName, false);
        };
        $options->schedulerWorkerActionMessage = 'Resuming the Scheduler Worker';

        $this->sendSignal($options);
    }
726553
public function reset()
    {
        foreach ($this->tasks as $task) {
            curl_multi_remove_handle($this->mh, $task['handle']);
        }

        curl_multi_close($this->mh);

        $this->mh = null;
        $this->tasks = [];

        return $this;
    }
676617
public function restart()
    {
        $workersArgs = $this->ResqueStatus->getWorkers();

        $this->params['all'] = true;
        $this->stop();

        $this->out('<info>' . __d('cake_resque', 'Restarting workers') . '</info>');
        if (!empty($workersArgs)) {
            $debug = $this->params['debug'];
            $this->debug(__d('cake_resque', 'Found ' . count($workersArgs) . ' workers to restart'));

            foreach ($workersArgs as $workerArgs) {
                $workerArgs['debug'] = $debug;
                if (isset($workerArgs['type']) && $workerArgs['type'] === 'scheduler') {
                    $this->startScheduler($workerArgs);
                } else {
                    $this->start($workerArgs);
                }
            }
            $this->out('');
        } else {
            $this->out('<warning>' . __d('cake_resque', 'No active workers found, will start brand new worker') . '</warning>');
            $this->start();
        }
    }
378384
public function doneWorking()
	{
		$this->currentJob = null;
		Resque_Stat::incr('processed');
		Resque_Stat::incr('processed:' . (string)$this);
		Resque::redis()->del('worker:' . (string)$this);
	}
711672
public function launch()
    {
        // Normalize sets setting to an array:
        $sets = (array)$this->set;
        if (empty($sets)) {
            $sets = [null];
        }

        // Load last state, if applicable (used to recover from server failure).
        if ($state = $this->stateManager->loadState()) {
            $this->write("Found saved state; attempting to resume.\n");
            list($resumeSet, $resumeToken, $this->startDate) = $state;
        }

        // Loop through all of the selected sets:
        foreach ($sets as $set) {
            // If we're resuming and there are multiple sets, find the right one.
            if (isset($resumeToken) && $resumeSet != $set) {
                continue;
            }

            // If we have a token to resume from, pick up there now...
            if (isset($resumeToken)) {
                $token = $resumeToken;
                unset($resumeToken);
            } else {
                // ...otherwise, start harvesting at the requested date:
                $token = $this->getRecordsByDate(
                    $this->startDate, $set, $this->harvestEndDate
                );
            }

            // Keep harvesting as long as a resumption token is provided:
            while ($token !== false) {
                // Save current state in case we need to resume later:
                $this->stateManager->saveState($set, $token, $this->startDate);
                $token = $this->getRecordsByToken($token);
            }
        }

        // If we made it this far, all was successful, so we should clean up
        // the stored state.
        $this->stateManager->clearState();
    }
27083
public function reset(): void
    {
        foreach ($this->sources as $source) {
            $source->setHasNotChanged();
        }

        $this->newSources = [];
    }
336634
protected function adjustRunningWorkers() : void
    {
        foreach ($this->poolsConfig as $pool => $workerConfig) {
            $workersActive = count($this->pids[$pool]);
            $workersTarget = (int)$workerConfig['instances'];
            if ($workersActive >= $workersTarget) {
                continue;
            }

            $workerDiff = $workersTarget - $workersActive;
            for ($i = 0; $i < $workerDiff; $i++) {
                $this->startupWorker($pool);
            }
        }
    }
180893
public function gracefulRestart()
    {
        $this->graceful = true;
        $this->reload = true;
        Timer::add(function () {
            EventLoop::$instance->stop();
        }, $this->reloadDelay * 1e6);
        $this->setState($this->state);
    }
979976
protected function checkPause()
    {
        parent::checkPause();

        foreach ($this->slaves as $slave) {
            $this->checkSlave($slave);
        }
    }
74357
public function restartCommand(): void
    {
        $daemon = $this->input->getSameOpt(['d', 'daemon']);

        $this->createServer()->asDaemon($daemon)->restart();
    }
335714
protected function shutdownWorkers()
    {
        $workers = Resque_Worker::all();

        foreach ($workers as $worker) {
            list($name, $pid, $queues) = explode(':', (string) $worker);
            posix_kill((int) $pid, SIGQUIT);
        }

        $this->output->writeln('<info>SIGQUIT sent to '.count($workers).' workers.</info>');
    }
1349171
protected static function reload()
    {
        // For master process.
        if (static::$_masterPid === posix_getpid()) {
            // Set reloading state.
            if (static::$_status !== static::STATUS_RELOADING && static::$_status !== static::STATUS_SHUTDOWN) {
                static::log("Workerman[" . basename(static::$_startFile) . "] reloading");
                static::$_status = static::STATUS_RELOADING;
                // Try to emit onMasterReload callback.
                if (static::$onMasterReload) {
                    try {
                        call_user_func(static::$onMasterReload);
                    } catch (\Exception $e) {
                        static::log($e);
                        exit(250);
                    } catch (\Error $e) {
                        static::log($e);
                        exit(250);
                    }
                    static::initId();
                }
            }

            if (static::$_gracefulStop) {
                $sig = SIGQUIT;
            } else {
                $sig = SIGUSR1;
            }

            // Send reload signal to all child processes.
            $reloadable_pid_array = array();
            foreach (static::$_pidMap as $worker_id => $worker_pid_array) {
                $worker = static::$_workers[$worker_id];
                if ($worker->reloadable) {
                    foreach ($worker_pid_array as $pid) {
                        $reloadable_pid_array[$pid] = $pid;
                    }
                } else {
                    foreach ($worker_pid_array as $pid) {
                        // Send reload signal to a worker process which reloadable is false.
                        posix_kill($pid, $sig);
                    }
                }
            }

            // Get all pids that are waiting reload.
            static::$_pidsToRestart = array_intersect(static::$_pidsToRestart, $reloadable_pid_array);

            // Reload complete.
            if (empty(static::$_pidsToRestart)) {
                if (static::$_status !== static::STATUS_SHUTDOWN) {
                    static::$_status = static::STATUS_RUNNING;
                }
                return;
            }
            // Continue reload.
            $one_worker_pid = current(static::$_pidsToRestart);
            // Send reload signal to a worker process.
            posix_kill($one_worker_pid, $sig);
            // If the process does not exit after static::KILL_WORKER_TIMER_TIME seconds try to kill it.
            if(!static::$_gracefulStop){
                Timer::add(static::KILL_WORKER_TIMER_TIME, 'posix_kill', array($one_worker_pid, SIGKILL), false);
            }
        } // For child processes.
        else {
            reset(static::$_workers);
            $worker = current(static::$_workers);
            // Try to emit onWorkerReload callback.
            if ($worker->onWorkerReload) {
                try {
                    call_user_func($worker->onWorkerReload, $worker);
                } catch (\Exception $e) {
                    static::log($e);
                    exit(250);
                } catch (\Error $e) {
                    static::log($e);
                    exit(250);
                }
            }

            if ($worker->reloadable) {
                static::stopAll();
            }
        }
    }
1290105
protected function reset()
    {
        $this->user = null;
        $this->lastAttempted = null;
        $this->viaRemember = false;
        $this->loggedOut = false;
        $this->tokenRetrievalAttempted = false;
        $this->recallAttempted  = false;
    }
798640
def _resume(self):
        """"""
        try:
            self._cursor.close()
        except PyMongoError:
            pass
        self._cursor = self._create_cursor()
1189189
public function pause()
    {
        $this->paused = true;

        if($this->getProcess()->getPid() == getmypid()) {
            $this->getLogger()->notice('SIGUSR2 received; pausing job processing');
        }else{
            $this->getProcess()->kill(SIGUSR2);
        }

    }
1108320
protected function attachUserProcesses(): void
    {
        // create Reload Worker
        if ($reloader = $this->createHotReloader()) {
            $this->server->addProcess($reloader);
        }

        foreach ($this->processCallbacks as $name => $callback) {
            $this->createProcess($name, $callback);
        }
    }
1352658
public function reset()
    {
        $this->debug('Emptying the worker database');
        $this->ResqueStatus->clearWorkers();
        $this->debug('Unregistering the scheduler worker');
        $this->ResqueStatus->unregisterSchedulerWorker();
        $this->output->outputLine('Fresque state has been reseted', 'success');
    }