如何在Pybossa中配置Webhook

如何在Pybossa中配置Webhook

本文介绍了如何在Pybossa中配置Webhook的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Pybossa没有描述如何配置Webhook.

The Pybossa didn't describe how to configure webhook.

我在配置Webhook时遇到了一些问题,以下是我的步骤:

I met some issue when I'm configuring webhook, below is my steps:

  1. fork pybossa webhook 示例
  2. 使用默认设置(已修改的api_key和端点)运行webhook.
  3. 在Pybossa中,修改项目并添加webhook以指向webhook运行URL.
  4. 打开命令行窗口并执行以下命令:
  1. fork pybossa webhook example
  2. Run webhook with default settings(modified api_key and endpoint).
  3. In Pybossa, modify the project and add webhook to point to webhook running URL.
  4. Open a command line window and execute the following command:

然后,当任务完成时,我看到命令行窗口中有日志.这是抱怨以下我得到以下错误:

Then when a task is completed, I see there are logs in command line window. which is complaining the following I get the below error:

14:06:11 *** Listening on high...
14:07:42 high: pybossa.jobs.webhook(u'http://192.168.116.135:5001', {'project_short_name': u'tw', 'task_id': 172, 'fired_at': '2017-08-10 06:07:42', 'project_id': 17, 'result_id': 75, 'event': 'task_completed'}) (e435386c-615d-4525-a65d-f08f0afd2351)
14:07:44 UnboundLocalError: local variable 'project' referenced before assignment
Traceback (most recent call last):
  File "/home/baib2/Desktop/pybossa_server/env/local/lib/python2.7/site-packages/rq/worker.py", line 479, in perform_job
      rv = job.perform()
  File "/home/baib2/Desktop/pybossa_server/env/local/lib/python2.7/site-packages/rq/job.py", line 466, in perform
      self._result = self.func(*self.args, **self.kwargs)
  File "./pybossa/jobs.py", line 525, in webhook
      if project.published and webhook.response_status_code != 200 and current_app.config.get('ADMINS'):
  UnboundLocalError: local variable 'project' referenced before assignment

我不确定我们是否应该执行以下命令

I'm not sure if we should execute the following command

但是如果该rqworker没有运行,我看不到任何组件从redis队列中接手工作.

But if this rqworker not running, I don't see any component picking up work from the redis queue.

推荐答案

您需要运行特定的工作程序,而不是PYBOSSA中的默认工作程序.只需使用 https://github.com/Scifabric/pybossa/blob/master/app_context_rqworker.py 以如下方式运行它:

You need to run a specific worker, not the default one from PYBOSSA. Just use https://github.com/Scifabric/pybossa/blob/master/app_context_rqworker.py to run it like this:

python app_context_rqworker.py高

python app_context_rqworker.py high

这将设置Flask上下文,并且将正常运行;-)

This will set up the Flask context, and it will run properly ;-)

我们正在改进文档,因此在接下来的几个月中应该会更好.

We're in the middle of improving our docs, so this should be better in the coming months.

这篇关于如何在Pybossa中配置Webhook的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-11 12:10