PHP Conference Japan 2024

GearmanWorker 類別

(PECL gearman >= 0.5.0)

簡介

類別概要

class GearmanWorker {
/* 方法 */
public __construct()
public addFunction(
    字串 $function_name,
    可呼叫 $function,
    混合型別 (mixed) $context = null,
    整數 (int) $timeout = 0
): 布林值 (bool)
公開 (public) addOptions(整數 (int) $option): 真 (true)
公開 (public) addServer(字串 (string) $host = null, 整數 (int) $port = 0, 布林值 (bool) $setupExceptionHandler = true): 布林值 (bool)
公開 (public) addServers(字串 (string) $servers = null, 布林值 (bool) $setupExceptionHandler = true): 布林值 (bool)
公開 (public) error(): 字串 (string) | 假 (false)
公開 (public) getErrno(): 整數 (int)
公開 (public) options(): 整數 (int)
公開 (public) register(字串 (string) $function_name, 整數 (int) $timeout = 0): 布林值 (bool)
公開 (public) removeOptions(整數 (int) $option): 真 (true)
公開 (public) returnCode(): 整數 (int)
公開 (public) setId(字串 (string) $id): 布林值 (bool)
公開 setOptions(整數 $option):
公開 setTimeout(整數 $timeout):
公開 timeout(): 整數
公開 unregister(字串 $function_name): 布林值
公開 wait(): 布林值
公開 work(): 布林值
}

目錄

新增註釋

使用者貢獻的註釋 2 則註釋

szhvoj@gmail!com
2 年前
使用 systemd 管理此程序

---- 8< ---- /lib/systemd/system/gearman-worker.service
[單元]
描述=我自己的 gearman worker

[服務]
執行指令=/usr/bin/php /var/www/my-worker.php
重新啟動=總是

[安裝]
WantedBy=multi-user.target
---- >8 ---- /lib/systemd/system/gearman-worker.service
systemctl daemon-reload
systemctl enable gearman-worker
systemctl start gearman-worker
spacewalker2002 at ukr dot net
11 年前
若要背景執行,請使用

exec("nohup php worker.php >/dev/null 2>/dev/null &");
To Top