顯示具有 Gearman 標籤的文章。 顯示所有文章
顯示具有 Gearman 標籤的文章。 顯示所有文章

2014年12月30日 星期二

Python get gearman job queue status

import gearman
gm_admin_client = gearman.GearmanAdminClient(['localhost:4730'])
status_response = gm_admin_client.get_status()
print status_response




References :
1.3. gearman.admin_client — Gearman Admin client — python-gearman v2.0.2 documentation

2014年10月14日 星期二

Job Queue / Task Queue / Message Queue

Job Queue
Client <-> Gearman <-> Worker
Synchronize, Asynchronous

Message Queue and Socket Programming

write in Python
no client and worker
queuing task and do task in background
Celery + RabbitMQ for "data" queue in Instragram
Celery doing task and queuing data in RabbitMQ

RabbitMQ :

Message Queue
Work queues : Publish (task) / Subscribe (worker)




Queues

2014年7月10日 星期四

查詢 Gearman 狀態

$ gearadmin --status

Column Explanation :
  1. Function Name
  2. Number in queue
  3. Number of jobs running
  4. Number of capable workers
 
 
 
 
 
References :
php - Gearman gearadmin command line tool status output meaning - Stack Overflow 

2014年6月30日 星期一

ImportError: No module named gearman

# pip install gearman

Gearman 使用 MySQL 作爲 job queue

* 工作在執行完後會從資料庫刪除


安裝編譯相關套件:
# apt-get build-dep gearman-job-server
# apt-get install gperf libmysqlclient-dev libmysqld-dev

下載 Gearman :
https://launchpad.net/gearmand

$ wget https://launchpad.net/gearmand/1.2/1.1.12/+download/gearmand-1.1.12.tar.gz
$ tar zxf gearmand-1.1.12.tar.gz
$ cd gearmand-1.1.12
$ ./configure --prefix=/opt/gearman
   ...
   ...
   ...
   * CPP Flags:                  -fvisibility=hidden
   * LIBS:                    
   * LDFLAGS Flags:           
   * Assertions enabled:        no
   * Debug enabled:             no
   * Warnings as failure:       no
   * Building with libsqlite3   yes
   * Building with libdrizzle   yes
   * Building with libmemcached yes
   * Building with libpq        yes
   * Building with tokyocabinet no
   * Building with libmysql     yes
   * SSL enabled:               no
   * cyassl found:              no
   * openssl found:             yes
   * make -j:                   2
   * VCS checkout:              no
   * sphinx-build:              :
$ make
# make install


新增資料庫:
CREATE DATABASE gearman;
CREATE TABLE gearman_queue ( 
    unique_key VARCHAR(255),
    function_name VARCHAR(255),
    priority INT,
    data LONGBLOB,
    when_to_run BIGINT,
    unique key (unique_key, function_name)
);

 
啓動:
# /opt/gearman/sbin/gearmand --log-file=/var/log/gearmand.log --queue-type=MySQL --mysql-host=127.0.0.1 --mysql-user=gearman --mysql-password=gearman --mysql-db=gearman --mysql-table=gearman_queue --mysql-port=3306 





References :
【CentOS】Gearman のジョブを MySQL に保存する - pospomeのプログラミング日記
生活在別處 : Gearman 安装及常见问题

舊:
Using Persistent Storage with Gearman | LornaJane