Github user hustfxj commented on a diff in the pull request:
https://github.com/apache/storm/pull/849#discussion_r45436295
--- Diff: storm-core/src/clj/backtype/storm/command/healthcheck.clj ---
@@ -0,0 +1,88 @@
+;; Licensed to the Apache Software Foundation (ASF) under one
+;; or more contributor license agreements. See the NOTICE file
+;; distributed with this work for additional information
+;; regarding copyright ownership. The ASF licenses this file
+;; to you under the Apache License, Version 2.0 (the
+;; "License"); you may not use this file except in compliance
+;; with the License. You may obtain a copy of the License at
+;;
+;; http://www.apache.org/licenses/LICENSE-2.0
+;;
+;; Unless required by applicable law or agreed to in writing, software
+;; distributed under the License is distributed on an "AS IS" BASIS,
+;; WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+;; See the License for the specific language governing permissions and
+;; limitations under the License.
+(ns backtype.storm.command.healthcheck
+ (:require [backtype.storm
+ [config :refer :all]
+ [log :refer :all]]
+ [clojure.java [io :as io]]
+ [clojure [string :refer [split]]])
+ (:gen-class))
+
+(defn interrupter
+ "Interrupt a given thread after ms milliseconds."
+ [thread ms]
+ (let [interrupter (Thread.
+ (fn []
+ (try
+ (Thread/sleep ms)
+ (.interrupt thread)
+ (catch InterruptedException e))))]
+ (.start interrupter)
+ interrupter))
+
+(defn check-output [lines]
+ (if (some #(.startsWith % "ERROR") lines)
+ :failed
+ :success))
+
+(defn process-script [conf script]
+ (let [script-proc (. (Runtime/getRuntime) (exec script))
+ curthread (Thread/currentThread)
+ interrupter-thread (interrupter curthread
+ (conf
STORM-HEALTH-CHECK-TIMEOUT-MS))]
+ (try
+ (.waitFor script-proc)
+ (.interrupt interrupter-thread)
--- End diff --
@revans2 If script-proc is blockedï¼then throw InterruptedException and
println "Script" script "timed out.".But the script-proc isn't really stop.Like
that:
admin 12755 1 0 12:49 pts/0 00:00:00 /bin/sh
/home/admin/test/healthCheck.sh
admin 12978 1 0 12:50 pts/0 00:00:00 /bin/sh
/home/admin/test/healthCheck.sh
admin 13228 1 0 12:51 pts/0 00:00:00 /bin/sh
/home/admin/test/healthCheck.sh
admin 13504 1 0 12:52 pts/0 00:00:00 /bin/sh
/home/admin/test/healthCheck.sh
admin 13644 13465 0 12:52 pts/0 00:00:00 /bin/sh
/home/admin/test/healthCheck.sh
Maybe we can stop the process ?
(defn interrupter
+ "Interrupt a given thread after ms milliseconds."
+ [script-proc ms]
+ (let [interrupter (Thread.
+ (fn []
+ (try
+ (Thread/sleep ms)
+ (.destory script-proc)
+ (catch InterruptedException e))))]
+ (.start interrupter)
+ interrupter))
---
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 [email protected] or file a JIRA ticket
with INFRA.
---