seamusabshere-daemon-spawn 0.2.4 → 0.2.5

Sign up to get free protection for your applications and to get access to all the features.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.2.4
1
+ 0.2.5
data/lib/daemon_spawn.rb CHANGED
@@ -46,14 +46,10 @@ module DaemonSpawn
46
46
  puts "#{daemon.app_name} started."
47
47
  end
48
48
 
49
- def self.still_alive?(pid)
50
- alive = true
51
- begin
52
- Process.kill 0, pid
53
- rescue Errno::ESRCH
54
- alive = false
55
- end
56
- alive
49
+ def self.alive?(pid)
50
+ Process.kill 0, pid
51
+ rescue Errno::ESRCH
52
+ false
57
53
  end
58
54
 
59
55
  def self.stop(daemon) #:nodoc:
@@ -67,12 +63,12 @@ module DaemonSpawn
67
63
 
68
64
  # just in case...
69
65
  ticks = daemon.timeout
70
- while ticks > 0 and still_alive?(pid) do
66
+ while ticks > 0 and alive?(pid) do
71
67
  puts "Process is still alive. #{ticks} seconds until I kill -9 it..."
72
68
  sleep 1
73
69
  ticks -= 1
74
70
  end
75
- if still_alive?(pid)
71
+ if alive?(pid)
76
72
  puts "Process didn't quit after timeout of #{daemon.timeout} seconds. Killing..."
77
73
  Process.kill 9, pid
78
74
  end
@@ -126,12 +122,8 @@ module DaemonSpawn
126
122
  end
127
123
 
128
124
  def alive? #:nodoc:
129
- if File.file?(self.pid_file)
130
- begin
131
- Process.kill(0, self.pid)
132
- rescue Errno::ESRCH, ::Exception
133
- false
134
- end
125
+ if File.file?(pid_file)
126
+ self.class.alive? pid
135
127
  else
136
128
  false
137
129
  end
@@ -181,14 +173,14 @@ module DaemonSpawn
181
173
  end
182
174
  end
183
175
 
176
+ # Start daemons(s) unless at least one is running
184
177
  def self.start(opts, args)
185
- daemons = find(opts)
186
- if daemons.empty?
187
- daemons = build(opts)
188
- daemons.map { |d| DaemonSpawn.start(d, args) }
189
- else
190
- puts "Daemons already started! PIDS: #{daemons.map {|d| d.pid}.join(', ')}"
178
+ living_daemons = find(opts).select { |d| d.alive? }
179
+ if living_daemons.any?
180
+ puts "Daemons are still alive! PIDS: #{living_daemons.map {|d| d.pid}.join(', ')}"
191
181
  exit 1
182
+ else
183
+ build(opts).map { |d| DaemonSpawn.start(d, args) }
192
184
  end
193
185
  end
194
186
 
@@ -0,0 +1,56 @@
1
+ # Generated by jeweler
2
+ # DO NOT EDIT THIS FILE DIRECTLY
3
+ # Instead, edit Jeweler::Tasks in Rakefile, and run the gemspec command
4
+ # -*- encoding: utf-8 -*-
5
+
6
+ Gem::Specification.new do |s|
7
+ s.name = %q{seamusabshere-daemon-spawn}
8
+ s.version = "0.2.5"
9
+
10
+ s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
+ s.authors = ["Alex Vollmer"]
12
+ s.date = %q{2010-07-13}
13
+ s.description = %q{gem 0.3.0 re-release... originally at http://github.com/alexvollmer/daemon-spawn}
14
+ s.email = %q{seamus@abshere.net}
15
+ s.extra_rdoc_files = [
16
+ "README.txt"
17
+ ]
18
+ s.files = [
19
+ ".autotest",
20
+ ".gitignore",
21
+ "History.txt",
22
+ "Manifest.txt",
23
+ "README.txt",
24
+ "Rakefile",
25
+ "VERSION",
26
+ "daemon-spawn.gemspec",
27
+ "lib/daemon_spawn.rb",
28
+ "seamusabshere-daemon-spawn.gemspec",
29
+ "test/daemon_spawn_test.rb",
30
+ "test/multi_daemon_spawn_test.rb",
31
+ "test/servers/echo_server.rb",
32
+ "test/servers/simple_server.rb"
33
+ ]
34
+ s.homepage = %q{http://github.com/seamusabshere/daemon-spawn}
35
+ s.rdoc_options = ["--charset=UTF-8"]
36
+ s.require_paths = ["lib"]
37
+ s.rubygems_version = %q{1.3.7}
38
+ s.summary = %q{A simple, flexible daemon management library. (re-released by Seamus Abshere)}
39
+ s.test_files = [
40
+ "test/daemon_spawn_test.rb",
41
+ "test/multi_daemon_spawn_test.rb",
42
+ "test/servers/echo_server.rb",
43
+ "test/servers/simple_server.rb"
44
+ ]
45
+
46
+ if s.respond_to? :specification_version then
47
+ current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
48
+ s.specification_version = 3
49
+
50
+ if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
51
+ else
52
+ end
53
+ else
54
+ end
55
+ end
56
+
metadata CHANGED
@@ -1,12 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: seamusabshere-daemon-spawn
3
3
  version: !ruby/object:Gem::Version
4
+ hash: 29
4
5
  prerelease: false
5
6
  segments:
6
7
  - 0
7
8
  - 2
8
- - 4
9
- version: 0.2.4
9
+ - 5
10
+ version: 0.2.5
10
11
  platform: ruby
11
12
  authors:
12
13
  - Alex Vollmer
@@ -14,7 +15,7 @@ autorequire:
14
15
  bindir: bin
15
16
  cert_chain: []
16
17
 
17
- date: 2010-05-20 00:00:00 -04:00
18
+ date: 2010-07-13 00:00:00 -05:00
18
19
  default_executable:
19
20
  dependencies: []
20
21
 
@@ -36,6 +37,7 @@ files:
36
37
  - VERSION
37
38
  - daemon-spawn.gemspec
38
39
  - lib/daemon_spawn.rb
40
+ - seamusabshere-daemon-spawn.gemspec
39
41
  - test/daemon_spawn_test.rb
40
42
  - test/multi_daemon_spawn_test.rb
41
43
  - test/servers/echo_server.rb
@@ -50,23 +52,27 @@ rdoc_options:
50
52
  require_paths:
51
53
  - lib
52
54
  required_ruby_version: !ruby/object:Gem::Requirement
55
+ none: false
53
56
  requirements:
54
57
  - - ">="
55
58
  - !ruby/object:Gem::Version
59
+ hash: 3
56
60
  segments:
57
61
  - 0
58
62
  version: "0"
59
63
  required_rubygems_version: !ruby/object:Gem::Requirement
64
+ none: false
60
65
  requirements:
61
66
  - - ">="
62
67
  - !ruby/object:Gem::Version
68
+ hash: 3
63
69
  segments:
64
70
  - 0
65
71
  version: "0"
66
72
  requirements: []
67
73
 
68
74
  rubyforge_project:
69
- rubygems_version: 1.3.6
75
+ rubygems_version: 1.3.7
70
76
  signing_key:
71
77
  specification_version: 3
72
78
  summary: A simple, flexible daemon management library. (re-released by Seamus Abshere)