gearman

Stopping gearman workers nicely

北城余情 提交于 2019-12-03 01:10:10
问题 I have a number of Gearman workers running constantly, saving things like records of user page views, etc. Occasionally, I'll update the PHP code that is used by the Gearman workers. In order to get the workers to switch to the new code, I the kill and restart the PHP processes for the workers. What is a better way to do this? Presumably, I'm sometime losing data (albeit not very important data) when I kill one of those worker processes. Edit: I found an answer that works for me, and posted

Problem With Gearman Job Status

荒凉一梦 提交于 2019-12-03 00:41:50
I have a Gearman server running a process which takes a few minutes to finish. I'm running a progress bar to show completion, and am attempting to get the percentages for the bar using the Gearman PHP extension and the jobStatus() function. The job is definitely active and found, as the first two fields (known + still running) return to true. However the third and fourth fields (numerator and denominator of completion percentage) return with nothing. Does anyone know why this might be or how these numbers are computed? public bool GearmanJob::sendStatus ( int $numerator , int $denominator )

Gearman gearadmin command line tool status output meaning

余生颓废 提交于 2019-12-02 23:29:32
I am unable to find any documentation on the meaning of the gearadmin command line tool with the '--status' option. What is the meaning of the three numbers found after the worker function name ? For example, then I run this command: gearadmin --status I get the following output: worker-function-name 114 0 0 . I don't know the meaning of the three numbers after the 'worker-function-name'. I don't think it matters but I'm using gearman with the php extension and ubuntu 13.10 server. Mark Baker Function Name Number in queue Number of jobs running Number of capable workers https://preilly.me

Calabash+Gearman实现多手机同步测试机制

天大地大妈咪最大 提交于 2019-12-02 19:30:52
摘要: Calabash-android是支持android的UI自动化测试框架,但不支持多手机同步测试。本文介绍如何利用任务分发系统Gearman的消息同步机制,配合Gearman实现多手机同步测试机制。 背景介绍 Calabash-android是支持android的UI自动化测试框架。 http://www.oschina.net/p/calabash-android Gearman是一个分发任务的程序框架,可以用在各种场合,与Hadoop相比,Gearman更偏向于任务分发功能。它的 任务分布非常 简单,简单得可以只需要用脚本即可完成。 http://www.oschina.net/p/gearman Ubuntu上安装Gearman $ sudo apt-get install gearman-job-server $ gearmand -V gearmand 1.0.6 - https://bugs.launchpad.net/gearmand $ sudo apt-get install gearman-tools $ gearman -H 启动gearman job server,作为后台服务运行: $ sudo gearmand -d 多手机同步测试举例 假设要测试微信的发送消息功能,calabash的测试用例可以按如下方式撰写: AA-send-message

Stopping gearman workers nicely

余生颓废 提交于 2019-12-02 14:28:44
I have a number of Gearman workers running constantly, saving things like records of user page views, etc. Occasionally, I'll update the PHP code that is used by the Gearman workers. In order to get the workers to switch to the new code, I the kill and restart the PHP processes for the workers. What is a better way to do this? Presumably, I'm sometime losing data (albeit not very important data) when I kill one of those worker processes. Edit: I found an answer that works for me, and posted it below. Solution 1 Generally I run my workers with the unix daemon utility with the -r flag and let

Gearman: is there still no way to retrieve custom data from a background worker?

时光总嘲笑我的痴心妄想 提交于 2019-12-02 05:17:10
问题 First things first, I'm aware of this question: Gearman: Sending data from a background worker to the client What I want to know, is it still the case with Gearman? I'm planning on sending a batch of image URLs from a PHP web application to the gearman worker (also written in PHP; let's call it "The Main Worker") for processing asynchronously. This worker will then submit a separate task for each image to lower-tier workers (via addTask()), call runTasks() and wait for the tasks to finish,

Gearman异步服务安装使用

落花浮王杯 提交于 2019-12-02 04:55:58
一、简介 gearman异步处理服务。 官网地址: http://gearman.org/ 二. 安装 1,安装管理软件仓库,添加gearman服务地址源 sudo apt-get install software-properties-common //管理软件仓库的程序 sudo add-apt-repository ppa:gearman-developers/ppa sudo apt-get update 2.安装GearmanJobServer、Dev Tools、Perform Upgrade sudo apt-get install gearman-job-server libgearman-dev //安装gearman相关扩展依赖 sudo apt-get install gearman-tools //gearman工具 sudo apt-get upgrade //更新软件,只更新gearman相关 3.如果没有PECL,安装PECL,并使用PECL安装Gearman(CLI,Client,Worker) sudo apt-get install php-pear sudo apt-get install php5-dev sudo pecl install gearman 4.修改php.ini(CLI and Server)to Use Gearman

并发利器 Gearman (一) 尝试

限于喜欢 提交于 2019-12-02 03:52:22
PHP 没有提供直接的并发功能。要实现并发,必须: function asyn_send(){ $fp = fsockopen('localhost', 80, &$errno, &$errstr, 5); if(!$fp){ echo "$errstr ($errno) /n"; } fputs($fp, "GET /sync.php?param=1&param2=2&a=c/r/n"); fclose($fp); } 要不然, PHP 会逐条代码执行,上一条执行完成后才会执行下一条。而上面这种方式处理扩展性不够强。 PHP 的 Gearman 库能把工作分发给一组机器。Gearman 会对作业进行排队并少量分派作业,而将那些复杂的任务分发给为此任务预留的机器。 这个库对 Perl、Ruby、C、Python 及 PHP 开发人员均可用,并且还可以运行于任何类似 UNIX® 的平台上,包括 Mac OS X、 Linux® 和 Sun Solaris。 向一个 PHP 应用程序添加 Gearman 非常简单。我们是将 PHP 应用程序托管在一个典型的 LAMP 配置上,那么 Gearman 将需要一个额外的守护程序以及一个 PHP 扩展。 安装 Gearman ====================== 向一个机器添加 Gearman 需要两步: 1.构建并启动这个守护程序 2

PHP实现异步任务分发处理利器-Gearman

旧巷老猫 提交于 2019-12-02 03:52:13
通常,多语言多系统之间的集成是个大问题,一般来说,人们多半会采用WebService的方式来处理此类集成问题,但不管采用何 种风格的WebService,如RPC风格,或者REST风格,其本身都有一定的复杂性。相比之下,Gearman也能实现类似的作用,而且更简单易 用。 一个Gearman请求的处理过程涉及三个角色:Client -> Job -> Worker。 Client:请求的发起者,可以是C,PHP,Perl, MySQL UDF等等。 Job:请求的调度者,用来负责协调把Client发出的请求转发给合适的Work。 Worker:请求的处理者,可以是C,PHP,Perl等等。 因为Client,Worker并不限制用一样的语言,所以有利于多语言多系统之间的集成。 甚至我们通过增加更多的Worker,可以很方便的实现应用程序的分布式负载均衡架构。 下面看看如何安装运行一个例子,条件所限,我们把Client,Job,Worker三个角色运行在一台服务器上: 安装Gearman server and library: wget http://launchpad.net/gearmand/trunk/0.8/+download/gearmand-0.8.tar.gz tar zxf gearmand-0.8.tar.gz cd gearmand-0.8 ./configure

Gearman Python接口使用

☆樱花仙子☆ 提交于 2019-12-02 03:51:59
Gearman是一个分布式任务调度框架,对于Gearman的介绍已有很多,本文主要记录下最近是用Gearman的python接口时遇到的小问题 python-Gearman目前版本2.0.1( http://www.gearman.org/python_client_library ),从1.x到2.x的变化不少,相关的区别文档中有详细说明( http://pythonhosted.org/gearman/ ),下文对其中部分做下翻译性的介绍。 Gearman worker:worker端,向server注册工作接口并执行具体任务。 GearmanWorker类描述了woker的工作。 例:(来自文档) gm_worker = gearman.GearmanWorker(['localhost:4730']) #反转字符串 def task_listener_reverse(gearman_worker, gearman_job): return reversed(gearman_job.data) #设置id是可选的 gm_worker.set_client_id('your_worker_client_id_name') gm_worker.register_task('reverse', task_listener_reverse) #进入工作循环 gm_worker