brooklyn-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From neykov <...@git.apache.org>
Subject [GitHub] brooklyn-server pull request #498: Use SIGTERM in stop script inside Abstrac...
Date Tue, 03 Jan 2017 15:22:39 GMT
Github user neykov commented on a diff in the pull request:

    https://github.com/apache/brooklyn-server/pull/498#discussion_r94417861
  
    --- Diff: software/base/src/main/java/org/apache/brooklyn/entity/software/base/AbstractSoftwareProcessSshDriver.java
---
    @@ -613,22 +614,29 @@ protected ScriptHelper newScript(Map<String, ?> flags, String
phase) {
                     // no pid, not running; 1 is not running
                     s.requireResultCode(Predicates.or(Predicates.equalTo(0), Predicates.equalTo(1)));
                 } else if (STOPPING.equals(phase)) {
    +                String stopCommand = Joiner.on('\n').join("PID=$(cat "+pidFile + ")",
    +                        "test -n \"$PID\" || exit 0",
    +                        "SIGTERM_USED=\"\"",
    +                        "for i in $(seq 1 16); do",
    +                        "  if ps -p $PID > /dev/null ; then",
    +                        "     kill $PID",
    +                        "     echo $PID is still running.",
    +                        "  else",
    +                        "     echo Process $PID stopped successfully.",
    +                        "     SIGTERM_USED=\"true\"",
    +                        "     break",
    +                        "  fi",
    +                        "  sleep 1",
    +                        "done",
    +                        "if test -z $SIGTERM_USED; then",
    +                        "  kill -9 $PID",
    +                        "  echo Process $PID stopped with SIGKILL",
    +                        "fi",
    +                        "rm " + pidFile);
    --- End diff --
    
    Use`-f` as previous code. If the file is read-only for whatever reason a prompt will appear,
potentially blocking execution.


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

Mime
View raw message