(r"/api/v1/jobs/([\w]{8}-[\w]{4}-[\w]{4}-[\w]{4}-[\w]{12})",
jobs.APIv1ControlHandler),
(r"/api/v1/jobs/([\w]{8}-[\w]{4}-[\w]{4}-[\w]{4}-[\w]{12})", jobs.APIv1IndexHandler),
+ (r"/api/v1/jobs/([\w]{8}-[\w]{4}-[\w]{4}-[\w]{4}-[\w]{12})/crashed",
+ jobs.APIv1CrashedHandler),
(r"/api/v1/jobs/([\w]{8}-[\w]{4}-[\w]{4}-[\w]{4}-[\w]{12})/log/stream",
jobs.APIv1LogStreamHandler),
pass
+class APIv1CrashedHandler(base.APIMixin, base.BackendMixin):
+ """
+ This handler is called by the daemon when a job has crashed.
+ """
+ # Don't allow users to authenticate
+ allow_users = False
+
+ @base.negotiate
+ async def post(self, job_id):
+ job = await self.backend.jobs.get_by_uuid(job_id)
+ if not job:
+ raise tornado.web.HTTPError(404, "Could not find job %s" % job_id)
+
+ # Check permissions
+ if not job.has_perm(self.current_user):
+ raise tornado.web.HTTPError(403)
+
+ # Signal
+ signo = self.get_argument_int("signo")
+
+ log.error("%s has been killed with signal %s" % (job, signo))
+
+ # XXX TODO
+
+ # Send an empty response
+ self.set_status(204)
+ self.finish()
+
+
class IndexHandler(base.BaseHandler):
async def get(self):
# Pagination