public function run($args) { $logger = LoggerFactory::getFileLogger('check_processes'); $logger->log(__METHOD__ . ' Start checkprocesses command.'); $criteria = new CDbCriteria(); $criteria->compare('stopped', 0); $connections = Listener::model()->findAll($criteria); $logger->log(__METHOD__ . ' Found ' . count($connections) . ' connections.'); foreach ($connections as $connection) { $logger->log(__METHOD__ . ' Listener info:', array('process_pid' => $connection->process_pid, 'listener_id' => $connection->listener_id, 'source' => $connection->source)); if (ProcessPid::isActiveProcess($connection->process_pid) === false) { ListenerProcess::addComment($connection->listener_id, 'comment', 'System found out that process is not active any more. Process will be re-run right now.'); Listener::stopConnection($connection->listener_id, time()); Listener::runConnection($connection->source, $connection->additional_param, 'auto'); } } // ProcessPid::killProcess(12376); $synchronization = new Synchronization(); if ($synchronization->isProcessed() && ProcessPid::isActiveProcess($synchronization->getTcpServerPid()) === false) { $synchronization->startTcpServer(); } if ($synchronization->isProcessed() && ProcessPid::isActiveProcess($synchronization->getTcpClientPid()) === false) { $synchronization->startTcpClient(); } }
protected function stopListenFromMasterForwardingMessages() { $source = 'TCP:' . $this->forwarding_messages_ip . ":" . $this->forwarding_messages_port; $last_connection = Listener::getLastConnectionInfoForSynch($source); if ($last_connection && !$last_connection['stopped']) { ProcessPid::killProcess($last_connection['process_pid']); ListenerProcess::addComment($last_connection['listener_id'], 'comment', 'Server has set master'); Listener::stopConnection($last_connection['listener_id']); $this->_configForm->updateParam('LISTENER_ID_FROM_MASTER', false); $this->_configForm->saveToFile(); } }
public function run() { $this->_logger->log(__CLASS__ . ' ' . __METHOD__); $this->_recognizeHardware(); switch ($this->hardware) { case 'com': new ProcessListenCom($this->_logger, $this->source, $this->by, $this->listener); break; case 'client': new ProcessListenClient($this->_logger, $this->source, $this->by, $this->listener); break; case 'poller': new ProcessListenPolling($this->_logger, $this->source, $this->by, $this->listener); break; case 'server': new ProcessListenServer($this->_logger, $this->source, $this->by, $this->listener); break; } ListenerProcess::addComment($this->listener->listener_id, 'stopped', 'Script execution was completed'); Listener::stopConnection($this->listener->listener_id); }
public function actionStopListening() { if (!$_REQUEST['source']) { echo json_encode(array('errors' => array('Unknown connection type'))); Yii::app()->end(); } $source = strtoupper($_REQUEST['source']); $last_connection = Listener::getLastConnectionInfo($source); if ($last_connection && !$last_connection['stopped']) { ProcessPid::killProcess($last_connection['process_pid']); ListenerProcess::addComment($last_connection['listener_id'], 'comment', 'Stop by user'); Listener::stopConnection($last_connection['listener_id']); } echo json_encode(array('ok' => 1)); Yii::app()->end(); }