with_pid 0.1.4 → 0.1.5
Sign up to get free protection for your applications and to get access to all the features.
- data/require.rb +1 -1
- data/templates/bash.erb +14 -5
- metadata +3 -3
data/require.rb
CHANGED
data/templates/bash.erb
CHANGED
@@ -22,15 +22,24 @@ case "<%= options[:action] %>" in
|
|
22
22
|
rm -f $PID_FILE
|
23
23
|
fi
|
24
24
|
echo $$ > $PID_FILE;
|
25
|
-
|
26
|
-
exec 2<&1 "$COMMAND"
|
27
|
-
<% else %>
|
28
|
-
exec 2<&1 su -c"$COMMAND"
|
29
|
-
<% end %>
|
25
|
+
eval "$COMMAND"
|
30
26
|
;;
|
31
27
|
stop)
|
32
28
|
echo "Stopping <%= options[:name] %>"
|
33
29
|
if [ -f $PID_FILE ]; then
|
30
|
+
for child in $(ps axo pid,ppid | awk "{ if ( \$2 == `cat $PID_FILE` ) { print \$1 }}");
|
31
|
+
do
|
32
|
+
kill -15 $child;
|
33
|
+
SLEEP_COUNT=0
|
34
|
+
while [ -e /proc/$child ]; do
|
35
|
+
sleep .25
|
36
|
+
let "SLEEP_COUNT+=1"
|
37
|
+
if(( "$SLEEP_COUNT" > 240 )); then
|
38
|
+
kill -9 $child 2>/dev/null; true
|
39
|
+
break
|
40
|
+
fi
|
41
|
+
done
|
42
|
+
done
|
34
43
|
kill -15 `cat $PID_FILE` 2>/dev/null; true
|
35
44
|
fi
|
36
45
|
[ -e "$PID_FILE" ] && rm -f $PID_FILE
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: with_pid
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 17
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 1
|
9
|
-
-
|
10
|
-
version: 0.1.
|
9
|
+
- 5
|
10
|
+
version: 0.1.5
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Winton Welsh
|