8 public function __construct()
10 $this->gmclient = new \GearmanClient();
11 $this->gmclient->addServer('127.0.0.1');
12 $this->queueName = $GLOBALS['phinde']['queuePrefix'] . 'phinde_process';
15 public function addToProcessList($linkUrl, $actions)
18 "Queuing for processing: $linkUrl"
19 . ' (' . implode(',', $actions) . ')'
22 $this->gmclient->doBackground(
27 'actions' => $actions,
31 if ($this->gmclient->returnCode() != GEARMAN_SUCCESS) {
33 'Error queueing URL processing for '
35 . 'Error code: ' . $this->gmclient->returnCode()
41 public function getServerStatus()
43 $cmd = 'gearadmin --status'
44 . '| grep ' . escapeshellarg($this->queueName);
48 $parts = [0, -1, -1, -1];
50 $parts = preg_split('#\s+#', $line);
51 if (count($parts) !== 4) {
52 throw new \Exception('gearadmin status line does not have 4 parts');
58 'processing' => $parts[2],
59 'workers' => $parts[3],