Github user poornachandra commented on a diff in the pull request:

    https://github.com/apache/twill/pull/2#discussion_r75523615
  
    --- Diff: 
twill-core/src/main/java/org/apache/twill/internal/TwillContainerLauncher.java 
---
    @@ -177,7 +187,22 @@ protected void doStartUp() {
     
         @Override
         protected void doShutDown() {
    -      // No-op
    +      // Wait for sometime for the container to stop
    +      // TODO: Use configurable value for stop time
    +      int maxWaitSecs = Constants.APPLICATION_MAX_STOP_SECONDS;
    +      try {
    +        if (shutdownLatch.await(maxWaitSecs, TimeUnit.SECONDS)) {
    +          return;
    +        }
    +      } catch (InterruptedException e) {
    +        LOG.error("Got exception while waiting for runnable {}, instance 
{} to stop", runnable, instanceId);
    +        // TODO: how do we handle the InterruptedException? Should we 
restore the interrupted status?
    +        return;
    +      }
    +      // Container has not shutdown even after maxWaitSecs after sending 
stop message,
    +      // we'll need to kill the container
    +      LOG.warn("Killing runnable {}, instance {} after waiting {} secs", 
runnable, instanceId, maxWaitSecs);
    +      kill();
    --- End diff --
    
    In case of exception during a kill, I'll add code to retry the kill a few 
times.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---

Reply via email to