From ce64ba0753cd30ce62199f9f31e3294d084b228a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sybren=20A=2E=20St=C3=BCvel?= <sybren@stuvel.eu> Date: Wed, 1 Feb 2017 09:55:51 +0100 Subject: [PATCH] Manager: added /timeout URL to kick the task timeout checker The task timeout checker runs periodically, but only starts 5 minutes after manager startup. This allows workers to push updates to the manager after downtime, before getting timed out. This /timeout URL is there to allow enforcing timeouts within that 5 minute window. --- .../src/flamenco-manager/flamenco/task_timeout_check.go | 4 ++-- .../flamenco-manager-go/src/flamenco-manager/main.go | 9 +++++++++ 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/packages/flamenco-manager-go/src/flamenco-manager/flamenco/task_timeout_check.go b/packages/flamenco-manager-go/src/flamenco-manager/flamenco/task_timeout_check.go index 3c21cd4d..c03ddccb 100644 --- a/packages/flamenco-manager-go/src/flamenco-manager/flamenco/task_timeout_check.go +++ b/packages/flamenco-manager-go/src/flamenco-manager/flamenco/task_timeout_check.go @@ -53,7 +53,7 @@ func (self *TaskTimeoutChecker) Go() { self.done_chan, self.done_wg) for _ = range timer { - self.check(db) + self.Check(db) } } @@ -65,7 +65,7 @@ func (self *TaskTimeoutChecker) Close() { log.Debug("TaskTimeoutChecker: shutdown complete.") } -func (self *TaskTimeoutChecker) check(db *mgo.Database) { +func (self *TaskTimeoutChecker) Check(db *mgo.Database) { timeout_threshold := UtcNow().Add(-self.config.ActiveTaskTimeoutInterval) log.Debugf("Failing all active tasks that have not been touched since %s", timeout_threshold) diff --git a/packages/flamenco-manager-go/src/flamenco-manager/main.go b/packages/flamenco-manager-go/src/flamenco-manager/main.go index cd44d366..bdccb1af 100644 --- a/packages/flamenco-manager-go/src/flamenco-manager/main.go +++ b/packages/flamenco-manager-go/src/flamenco-manager/main.go @@ -50,6 +50,14 @@ func http_kick(w http.ResponseWriter, r *http.Request) { fmt.Fprintln(w, "Kicked task downloader") } +func http_timeout(w http.ResponseWriter, r *http.Request) { + mongo_sess := session.Copy() + defer mongo_sess.Close() + task_timeout_checker.Check(mongo_sess.DB("")) + + fmt.Fprintln(w, "Kicked task timeouter") +} + func http_task_update(w http.ResponseWriter, r *auth.AuthenticatedRequest) { mongo_sess := session.Copy() defer mongo_sess.Close() @@ -209,6 +217,7 @@ func main() { router.HandleFunc("/may-i-run/{task-id}", worker_authenticator.Wrap(http_worker_may_run_task)).Methods("GET") router.HandleFunc("/sign-off", worker_authenticator.Wrap(http_worker_sign_off)).Methods("POST") router.HandleFunc("/kick", http_kick) + router.HandleFunc("/timeout", http_timeout) upstream.SendStartupNotification() go task_update_pusher.Go() -- GitLab