rake_server 0.0.6 → 0.0.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/VERSION +1 -1
- data/lib/rake_server/server.rb +19 -0
- data/rake_server.gemspec +1 -1
- metadata +2 -2
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.0.
|
1
|
+
0.0.7
|
data/lib/rake_server/server.rb
CHANGED
@@ -14,6 +14,16 @@ module RakeServer
|
|
14
14
|
class <<self
|
15
15
|
def start(eager_tasks, options = {})
|
16
16
|
pid_file = File.join(pid_dir(options), "rake-server.pid")
|
17
|
+
if File.exist?(pid_file)
|
18
|
+
running_pid = IO.read(pid_file).to_i
|
19
|
+
begin
|
20
|
+
Process.kill(0, running_pid)
|
21
|
+
raise "rake-server is already running on PID #{running_pid}"
|
22
|
+
rescue Errno::ESRCH
|
23
|
+
STDERR.puts("Cleaning stale PID file at #{pid_file}")
|
24
|
+
FileUtils.rm_f(pid_file)
|
25
|
+
end
|
26
|
+
end
|
17
27
|
read, write = IO.pipe
|
18
28
|
tmp_pid = fork do
|
19
29
|
read.close
|
@@ -22,6 +32,7 @@ module RakeServer
|
|
22
32
|
run(eager_tasks, options) do
|
23
33
|
write.write(Process.pid.to_s)
|
24
34
|
write.close
|
35
|
+
STDIN.reopen('/dev/null')
|
25
36
|
STDOUT.reopen('/dev/null')
|
26
37
|
STDERR.reopen(STDOUT)
|
27
38
|
end
|
@@ -40,6 +51,14 @@ module RakeServer
|
|
40
51
|
pid = IO.read(pid_file).to_i
|
41
52
|
begin
|
42
53
|
Process.kill("TERM", pid)
|
54
|
+
begin
|
55
|
+
loop do
|
56
|
+
Process.kill(0, pid)
|
57
|
+
sleep(0.1)
|
58
|
+
end
|
59
|
+
rescue Errno::ESRCH
|
60
|
+
# Process is dead
|
61
|
+
end
|
43
62
|
rescue Errno::ESRCH
|
44
63
|
STDERR.puts("No rake-server process running at PID #{pid}")
|
45
64
|
# No worries
|
data/rake_server.gemspec
CHANGED