You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@openwhisk.apache.org by GitBox <gi...@apache.org> on 2018/06/05 23:43:31 UTC

[GitHub] rabbah commented on a change in pull request #3704: Provide graceful shutdown for invoker

rabbah commented on a change in pull request #3704: Provide graceful shutdown for invoker
URL: https://github.com/apache/incubator-openwhisk/pull/3704#discussion_r193254857
 
 

 ##########
 File path: core/invoker/src/main/scala/whisk/core/invoker/InvokerReactive.scala
 ##########
 @@ -284,4 +290,50 @@ class InvokerReactive(
       })
   }
 
+  val healthScheduler = Scheduler.scheduleWaitAtMost(1.seconds)(() => {
+    producer.send("health", PingMessage(instance)).andThen {
+      case Failure(t) => logging.error(this, s"failed to ping the controller: $t")
+    }
+  })
+
+  private def gracefulShutdown: Unit = {
+    logging.info(this, s"Starting graceful shutdown")
+
+    try {
+      Await.result(gracefulStop(healthScheduler, 5.seconds), 6.seconds)
+    } catch {
+      case e: akka.pattern.AskTimeoutException =>
+        logging.info(this, "Health communication failed to shutdown gracefully")
+    }
+
+    try {
+      Await.result(gracefulStop(activationFeed, 5.seconds), 6.seconds)
+    } catch {
+      case e: akka.pattern.AskTimeoutException => logging.info(this, "Activation feed failed to shutdown gracefully")
+    }
+
+    implicit val timeout = Timeout(5 seconds)
+
+    while (Await.result(pool ? Busy, timeout.duration).asInstanceOf[Boolean] == true) {
+      logging.info(this, s"Container pool is busy")
+      Thread.sleep(1000)
+    }
 
 Review comment:
   Can you emit a log message while waiting for quiescence?

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services