分布式作业队列调度平台
kingarthur的Python项目详细描述
亚瑟王命令他的忠诚骑士珀塞瓦尔去寻找 来自软件存储库的数据。
Arthur是一个分布式作业队列平台,它调度和执行 珀西瓦尔。平台由两个组件组成:arthurd,即 调度作业和arthurw的一个或多个实例的服务器, 运行每个perceval作业的工作马。
将要获取数据的存储库添加到平台中 使用rest api。然后,服务器将这些存储库转换为 perceval作业并在其作业队列之间调度它们。
工人们正在等待新的工作检查这些队列。仅限工人 一次执行一个作业。当一个新工作到来时,一个无所事事的工人 拿着它跑。一旦作业完成,如果结果成功, 服务器将重新安排它以检索新数据。
默认情况下,每个作业获取的项将使用redis发布 排队。此外,它们可以写入弹性搜索索引。
用法
阿尔瑟德
usage: arthurd [-c <file>] [-g] [-h <host>] [-p <port>] [-d <database>] [--es-index <index>] [--log-path <path>] [--archive-path <cpath>] [--no-archive] [--no-daemon] | --help King Arthur commands his loyal knight Perceval on the quest to retrieve data from software repositories. This command runs an Arthur daemon that waits for HTTP requests on port 8080. Repositories to analyze are added using an REST API. Repositories are transformed into Perceval jobs that will be scheduled and run using a distributed job queue platform. optional arguments: -?, --help show this help message and exit -c FILE, --config FILE set configuration file -g, --debug set debug mode on -h, --host set the host name or IP address on which to listen for connections -p, --port set listening TCP port (default: 8080) -d, --database URL database connection (default: 'redis://localhost/8') -s, --sync work in synchronous mode (without workers) --es-index output ElasticSearch server index --log-path path where logs are stored --archive-path path to archive manager directory --no-archive do not archive fetched raw data --no-daemon do not run arthur in daemon mode
arthurd配置文件
使用配置文件运行arthurd:
$ arthurd [-c <file>]
其中<file>是使用相同文件的ini文件的路径 参数,但用连字符替换下划线。 此配置文件具有以下结构:
[arthur] archive_path=/tmp/.arthur/archive debug=True log_path=/tmp/logs/arthurd no_archive=True sync_mode=True [connection] host=127.0.0.1 port=8080 [elasticsearch] es_index=http://localhost:9200/items [redis] database=redis://localhost/8
阿瑟
usage: arthurw [-g] [-d <database>] [--burst] [<queue1>...<queueN>] | --help King Arthur's worker. It will run Perceval jobs on the quest to retrieve data from software repositories. positional arguments: queues list of queues this worker will listen for ('create' and 'update', by default) optional arguments: -?, --help show this help message and exit -g, --debug set debug mode on -d, --database URL database connection (default: 'redis://localhost/8') -b, --burst Run in burst mode (quit after all work is done)
要求
- python=3.4
- redis>;=2.3和<;3.0
- python3 dateutil>;=2.6
- Python3 redis>;=2.10,<;=2.10.6
- Python3 rq>;=0.6,<;=0.12.0
- Python3 Cherrypy>;=8.1.0和<;=11.0.0
- GrimoireLab工具包=0.1.8
- perceval=0.11.0
安装
$ pip3 install -r requirements.txt $ python3 setup.py install
如何运行它
第一步是运行将用于 传达亚瑟的成分。此外,一个弹性搜索服务器 可用于存储作业生成的项。请参考他们的 了解如何安装和运行它们的文档。
运行亚瑟服务器:
$ arthurd -g -d redis://localhost/8 --es-index http://localhost:9200/items --log-path /tmp/logs/arthud --no-archive
运行工作进程:
$ arthurw -d redis://localhost/8
添加任务
要向Arthur添加任务,请创建一个包含所需任务的JSON对象 从一组存储库中获取数据。每个任务将运行一个perceval 因此,每个任务也需要后端参数。
$ cat tasks.json { "tasks": [ { "task_id": "arthur.git", "backend": "git", "backend_args": { "gitpath": "/tmp/git/arthur.git/", "uri": "https://github.com/chaoss/grimoirelab-kingarthur.git", "from_date": "2015-03-01" }, "category": "commit", "scheduler": { "delay": 10 } }, { "task_id": "bugzilla_mozilla", "backend": "bugzillarest", "backend_args": { "url": "https://bugzilla.mozilla.org/", "from_date": "2016-09-19" }, "category": "bug", "archive": { "fetch_from_archive": true, "archived_after": "2018-02-26 09:00" }, "scheduler": { "delay": 60, "max_retries": 5 } } ] }
然后,将此json流发送到调用add方法的服务器。
$ curl -H "Content-Type: application/json" --data @tasks.json http://127.0.0.1:8080/add
对于本例,项将存储在 弹性搜索服务器(http://localhost:9200/items)。
列出任务
可以使用以下方法获取当前计划的任务列表 tasks。
$ curl http://127.0.0.1:8080/tasks { "tasks": [ { "backend_args": { "from_date": "2015-03-01T00:00:00+00:00", "uri": "https://github.com/chaoss/grimoirelab-kingarthur.git", "gitpath": "/tmp/santi/" }, "backend": "git", "category": "commit", "created_on": 1480531707.810326, "task_id": "arthur.git", "scheduler": { "max_retries": 3, "delay": 10 } } ] }
删除任务
也可以使用 remove方法。必须提供json流,设置 要删除的任务的标识符。
$ cat tasks_to_remove.json { "tasks": [ { "task_id": "bugzilla_mozilla" }, { "task_id": "arthur.git" } ] } $ curl -H "Content-Type: application/json" --data @tasks_to_remove.json http://127.0.0.1:8080/remove
许可证
根据GNU通用公共许可证(GPL)第3版或更高版本授权。