workers.py 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. from __future__ import absolute_import
  2. from tornado import web
  3. from ..models import WorkersModel
  4. from ..views import BaseHandler
  5. class ListWorkers(BaseHandler):
  6. @web.authenticated
  7. def get(self):
  8. """
  9. List workers
  10. **Example request**:
  11. .. sourcecode:: http
  12. GET /api/workers HTTP/1.1
  13. Host: localhost:5555
  14. **Example response**:
  15. .. sourcecode:: http
  16. HTTP/1.1 200 OK
  17. Content-Length: 119
  18. Content-Type: application/json; charset=UTF-8
  19. {
  20. "celery@worker1": {
  21. "completed_tasks": 0,
  22. "concurrency": 4,
  23. "queues": [
  24. "celery"
  25. ],
  26. "running_tasks": 0,
  27. "status": true
  28. },
  29. "celery@worker2": {
  30. "completed_tasks": 0,
  31. "concurrency": 4,
  32. "queues": [],
  33. "running_tasks": 0,
  34. "status": false
  35. }
  36. }
  37. :reqheader Authorization: optional OAuth token to authenticate
  38. :statuscode 200: no error
  39. :statuscode 401: unauthorized request
  40. """
  41. app = self.application
  42. self.write(WorkersModel.get_latest(app).workers)