How to configure webhook in Pybossa

时光总嘲笑我的痴心妄想 提交于 2020-01-07 07:37:37

问题


The Pybossa didn't describe how to configure webhook.

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

  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:

# rqworker high

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 high

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


回答1:


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 high

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.



来源:https://stackoverflow.com/questions/45606567/how-to-configure-webhook-in-pybossa

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!