daemon-spawn 0.4.1 → 0.4.2
Sign up to get free protection for your applications and to get access to all the features.
- data/History.txt +4 -0
- data/Rakefile +1 -1
- data/VERSION +1 -1
- data/lib/daemon_spawn.rb +4 -3
- data/test/daemon_spawn_test.rb +32 -6
- metadata +7 -7
- data/daemon-spawn.gemspec +0 -64
data/History.txt
CHANGED
data/Rakefile
CHANGED
@@ -15,7 +15,7 @@ begin
|
|
15
15
|
gemspec.rubyforge_project = "daemon-spawn"
|
16
16
|
gemspec.email = "alex.vollmer@gmail.com"
|
17
17
|
gemspec.homepage = "http://github.com/alexvollmer/daemon-spawn"
|
18
|
-
gemspec.authors = ["Alex Vollmer", "Seamus Abshere", "Emmanual Gomez", "Seth Falcon", "Woody Peterson"]
|
18
|
+
gemspec.authors = ["Alex Vollmer", "Seamus Abshere", "Emmanual Gomez", "Seth Falcon", "Woody Peterson", "Tilo Prütz"]
|
19
19
|
end
|
20
20
|
Jeweler::GemcutterTasks.new
|
21
21
|
rescue LoadError
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.4.
|
1
|
+
0.4.2
|
data/lib/daemon_spawn.rb
CHANGED
@@ -11,7 +11,7 @@ module DaemonSpawn
|
|
11
11
|
puts "Where <command> is one of start, stop, restart or status"
|
12
12
|
puts "[options] are additional options passed to the underlying process"
|
13
13
|
end
|
14
|
-
|
14
|
+
|
15
15
|
def self.alive?(pid)
|
16
16
|
Process.kill 0, pid
|
17
17
|
rescue Errno::ESRCH
|
@@ -40,8 +40,9 @@ module DaemonSpawn
|
|
40
40
|
exit if fork
|
41
41
|
open(daemon.pid_file, 'w') { |f| f << Process.pid }
|
42
42
|
Dir.chdir daemon.working_dir
|
43
|
-
File.umask 0000
|
43
|
+
old_umask = File.umask 0000
|
44
44
|
log = File.new(daemon.log_file, "a")
|
45
|
+
File.umask old_umask
|
45
46
|
log.sync = daemon.sync_log
|
46
47
|
STDIN.reopen "/dev/null"
|
47
48
|
STDOUT.reopen log
|
@@ -179,7 +180,7 @@ module DaemonSpawn
|
|
179
180
|
else
|
180
181
|
build(opts).map { |d| DaemonSpawn.start(d, args) }
|
181
182
|
end
|
182
|
-
end
|
183
|
+
end
|
183
184
|
|
184
185
|
def self.stop(opts, args)
|
185
186
|
daemons = find(opts)
|
data/test/daemon_spawn_test.rb
CHANGED
@@ -7,7 +7,7 @@ class DaemonSpawnTest < Test::Unit::TestCase
|
|
7
7
|
|
8
8
|
# Try to make sure no pidfile (or process) is left over from another test.
|
9
9
|
def setup
|
10
|
-
%w{ echo_server deaf_server stubborn_server }.each do |server|
|
10
|
+
%w{ echo_server deaf_server stubborn_server simple_server }.each do |server|
|
11
11
|
begin
|
12
12
|
Process.kill 9, possible_pid(server)
|
13
13
|
rescue Errno::ESRCH
|
@@ -38,20 +38,20 @@ class DaemonSpawnTest < Test::Unit::TestCase
|
|
38
38
|
`./echo_server.rb #{args.join(' ')}`
|
39
39
|
end
|
40
40
|
|
41
|
-
def while_running
|
41
|
+
def while_running(&block)
|
42
42
|
Dir.chdir(SERVERS) do
|
43
43
|
`./echo_server.rb stop`
|
44
44
|
assert_match(/EchoServer started./, `./echo_server.rb start 5150`)
|
45
45
|
sleep 1
|
46
46
|
begin
|
47
|
-
with_socket
|
47
|
+
with_socket &block
|
48
48
|
ensure
|
49
49
|
assert_match(//, `./echo_server.rb stop`)
|
50
50
|
assert_raises(Errno::ECONNREFUSED) { TCPSocket.new('127.0.0.1', 5150) }
|
51
51
|
end
|
52
52
|
end
|
53
53
|
end
|
54
|
-
|
54
|
+
|
55
55
|
def after_daemon_dies_leaving_pid_file
|
56
56
|
Dir.chdir(SERVERS) do
|
57
57
|
`./echo_server.rb stop`
|
@@ -129,7 +129,7 @@ class DaemonSpawnTest < Test::Unit::TestCase
|
|
129
129
|
end
|
130
130
|
end
|
131
131
|
end
|
132
|
-
|
132
|
+
|
133
133
|
def test_start_after_daemon_dies_leaving_pid_file
|
134
134
|
after_daemon_dies_leaving_pid_file do |leftover_pid|
|
135
135
|
assert_match /EchoServer started/, `./echo_server.rb start 5150`
|
@@ -149,7 +149,7 @@ class DaemonSpawnTest < Test::Unit::TestCase
|
|
149
149
|
assert alive?(new_pid)
|
150
150
|
end
|
151
151
|
end
|
152
|
-
|
152
|
+
|
153
153
|
def test_stop_using_custom_signal
|
154
154
|
Dir.chdir(SERVERS) do
|
155
155
|
`./deaf_server.rb start`
|
@@ -181,4 +181,30 @@ class DaemonSpawnTest < Test::Unit::TestCase
|
|
181
181
|
assert dead?(pid)
|
182
182
|
end
|
183
183
|
end
|
184
|
+
|
185
|
+
def test_umask_unchanged
|
186
|
+
Dir.chdir(SERVERS) do
|
187
|
+
old_umask = File.umask 0124
|
188
|
+
log_file = File.join(Dir.tmpdir, 'should_not_be_world_writable')
|
189
|
+
begin
|
190
|
+
`./simple_server.rb stop`
|
191
|
+
FileUtils.rm_f log_file
|
192
|
+
`./simple_server.rb start #{log_file}`
|
193
|
+
sleep 1
|
194
|
+
assert_equal 0100642, File.stat(log_file).mode
|
195
|
+
ensure
|
196
|
+
`./simple_server.rb stop`
|
197
|
+
FileUtils.rm_f log_file
|
198
|
+
File.umask old_umask
|
199
|
+
end
|
200
|
+
end
|
201
|
+
end
|
202
|
+
|
203
|
+
def test_log_file_is_world_writable
|
204
|
+
log_file = File.join(Dir.tmpdir, 'echo_server.log')
|
205
|
+
FileUtils.rm_f log_file
|
206
|
+
while_running do
|
207
|
+
assert_equal 0100666, File.stat(log_file).mode
|
208
|
+
end
|
209
|
+
end
|
184
210
|
end
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: daemon-spawn
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
5
|
-
prerelease:
|
4
|
+
hash: 11
|
5
|
+
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 4
|
9
|
-
-
|
10
|
-
version: 0.4.
|
9
|
+
- 2
|
10
|
+
version: 0.4.2
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Alex Vollmer
|
@@ -15,11 +15,12 @@ authors:
|
|
15
15
|
- Emmanual Gomez
|
16
16
|
- Seth Falcon
|
17
17
|
- Woody Peterson
|
18
|
+
- "Tilo Pr\xC3\xBCtz"
|
18
19
|
autorequire:
|
19
20
|
bindir: bin
|
20
21
|
cert_chain: []
|
21
22
|
|
22
|
-
date: 2011-
|
23
|
+
date: 2011-04-01 00:00:00 -07:00
|
23
24
|
default_executable:
|
24
25
|
dependencies: []
|
25
26
|
|
@@ -41,7 +42,6 @@ files:
|
|
41
42
|
- README.txt
|
42
43
|
- Rakefile
|
43
44
|
- VERSION
|
44
|
-
- daemon-spawn.gemspec
|
45
45
|
- lib/daemon_spawn.rb
|
46
46
|
- test/daemon_spawn_test.rb
|
47
47
|
- test/helper.rb
|
@@ -81,7 +81,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
81
81
|
requirements: []
|
82
82
|
|
83
83
|
rubyforge_project: daemon-spawn
|
84
|
-
rubygems_version: 1.
|
84
|
+
rubygems_version: 1.6.2
|
85
85
|
signing_key:
|
86
86
|
specification_version: 3
|
87
87
|
summary: Daemon launching and management made dead simple
|
data/daemon-spawn.gemspec
DELETED
@@ -1,64 +0,0 @@
|
|
1
|
-
# Generated by jeweler
|
2
|
-
# DO NOT EDIT THIS FILE DIRECTLY
|
3
|
-
# Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
|
4
|
-
# -*- encoding: utf-8 -*-
|
5
|
-
|
6
|
-
Gem::Specification.new do |s|
|
7
|
-
s.name = %q{daemon-spawn}
|
8
|
-
s.version = "0.4.1"
|
9
|
-
|
10
|
-
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
|
-
s.authors = ["Alex Vollmer", "Seamus Abshere", "Emmanual Gomez", "Seth Falcon", "Woody Peterson"]
|
12
|
-
s.date = %q{2011-03-03}
|
13
|
-
s.description = %q{With daemon-spawn you can start, stop and restart processes that run
|
14
|
-
in the background. Processed are tracked by a simple PID file written
|
15
|
-
to disk.}
|
16
|
-
s.email = %q{alex.vollmer@gmail.com}
|
17
|
-
s.extra_rdoc_files = [
|
18
|
-
"README.txt"
|
19
|
-
]
|
20
|
-
s.files = [
|
21
|
-
".autotest",
|
22
|
-
"History.txt",
|
23
|
-
"Manifest.txt",
|
24
|
-
"README.txt",
|
25
|
-
"Rakefile",
|
26
|
-
"VERSION",
|
27
|
-
"daemon-spawn.gemspec",
|
28
|
-
"lib/daemon_spawn.rb",
|
29
|
-
"test/daemon_spawn_test.rb",
|
30
|
-
"test/helper.rb",
|
31
|
-
"test/multi_daemon_spawn_test.rb",
|
32
|
-
"test/servers/deaf_server.rb",
|
33
|
-
"test/servers/echo_server.rb",
|
34
|
-
"test/servers/simple_server.rb",
|
35
|
-
"test/servers/stubborn_server.rb",
|
36
|
-
"test/servers/taps_server.rb"
|
37
|
-
]
|
38
|
-
s.homepage = %q{http://github.com/alexvollmer/daemon-spawn}
|
39
|
-
s.require_paths = ["lib"]
|
40
|
-
s.rubyforge_project = %q{daemon-spawn}
|
41
|
-
s.rubygems_version = %q{1.3.7}
|
42
|
-
s.summary = %q{Daemon launching and management made dead simple}
|
43
|
-
s.test_files = [
|
44
|
-
"test/daemon_spawn_test.rb",
|
45
|
-
"test/helper.rb",
|
46
|
-
"test/multi_daemon_spawn_test.rb",
|
47
|
-
"test/servers/deaf_server.rb",
|
48
|
-
"test/servers/echo_server.rb",
|
49
|
-
"test/servers/simple_server.rb",
|
50
|
-
"test/servers/stubborn_server.rb",
|
51
|
-
"test/servers/taps_server.rb"
|
52
|
-
]
|
53
|
-
|
54
|
-
if s.respond_to? :specification_version then
|
55
|
-
current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
|
56
|
-
s.specification_version = 3
|
57
|
-
|
58
|
-
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
59
|
-
else
|
60
|
-
end
|
61
|
-
else
|
62
|
-
end
|
63
|
-
end
|
64
|
-
|