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.
Files changed (3) hide show
  1. data/require.rb +1 -1
  2. data/templates/bash.erb +14 -5
  3. metadata +3 -3
data/require.rb CHANGED
@@ -13,7 +13,7 @@ Require do
13
13
  name 'with_pid'
14
14
  homepage "http://github.com/winton/#{name}"
15
15
  summary "The simple way to create and monitor a Ruby daemon"
16
- version '0.1.4'
16
+ version '0.1.5'
17
17
  end
18
18
 
19
19
  rakefile do
@@ -22,15 +22,24 @@ case "<%= options[:action] %>" in
22
22
  rm -f $PID_FILE
23
23
  fi
24
24
  echo $$ > $PID_FILE;
25
- <% if RUBY_PLATFORM.include?('darwin') %>
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: 19
4
+ hash: 17
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
8
  - 1
9
- - 4
10
- version: 0.1.4
9
+ - 5
10
+ version: 0.1.5
11
11
  platform: ruby
12
12
  authors:
13
13
  - Winton Welsh