mysql_isolated_server 0.1.1 → 0.2.0.rc1
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/lib/mysql_isolated_server/version.rb +1 -1
- data/lib/mysql_isolated_server.rb +42 -13
- metadata +5 -5
@@ -112,22 +112,51 @@ class MysqlIsolatedServer
|
|
112
112
|
devnull = File.open("/dev/null", "w")
|
113
113
|
system("mkdir -p #{base}/tmp")
|
114
114
|
system("chmod 0777 #{base}/tmp")
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
115
|
+
|
116
|
+
original_pid = $$
|
117
|
+
mysql_pid = nil
|
118
|
+
|
119
|
+
middle_pid = fork do
|
120
|
+
mysql_pid = fork do
|
121
|
+
ENV["TMPDIR"] = "#{base}/tmp"
|
122
|
+
if !@allow_output
|
123
|
+
STDOUT.reopen(devnull)
|
124
|
+
STDERR.reopen(devnull)
|
125
|
+
end
|
126
|
+
|
127
|
+
exec(cmd)
|
128
|
+
end
|
129
|
+
|
130
|
+
# begin waiting for the parent (or mysql) to die; at_exit is hard to control when interacting with test/unit
|
131
|
+
# we can also be killed by our parent with down! and up!
|
132
|
+
#
|
133
|
+
trap("TERM") do
|
134
|
+
Process.kill("KILL", mysql_pid) rescue nil
|
135
|
+
cleanup!
|
136
|
+
exit!
|
120
137
|
end
|
121
138
|
|
122
|
-
|
139
|
+
while true
|
140
|
+
begin
|
141
|
+
Process.kill(0, original_pid)
|
142
|
+
Process.kill(0, mysql_pid)
|
143
|
+
rescue Exception => e
|
144
|
+
Process.kill("KILL", mysql_pid) rescue nil
|
145
|
+
cleanup!
|
146
|
+
exit!
|
147
|
+
end
|
148
|
+
|
149
|
+
sleep 1
|
150
|
+
end
|
151
|
+
|
152
|
+
at
|
123
153
|
end
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
devnull.close
|
154
|
+
|
155
|
+
@pid = middle_pid
|
156
|
+
end
|
157
|
+
|
158
|
+
def cleanup!
|
159
|
+
system("rm -Rf #{base}")
|
131
160
|
end
|
132
161
|
|
133
162
|
def kill!
|
metadata
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: mysql_isolated_server
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
5
|
-
prerelease:
|
4
|
+
version: 0.2.0.rc1
|
5
|
+
prerelease: 6
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
8
8
|
- Ben Osheroff
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-
|
12
|
+
date: 2013-05-02 00:00:00.000000000 Z
|
13
13
|
dependencies: []
|
14
14
|
description: A small library that allows you to easily spin up new local mysql servers
|
15
15
|
for testing purposes.
|
@@ -45,9 +45,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
45
45
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
46
46
|
none: false
|
47
47
|
requirements:
|
48
|
-
- - ! '
|
48
|
+
- - ! '>'
|
49
49
|
- !ruby/object:Gem::Version
|
50
|
-
version:
|
50
|
+
version: 1.3.1
|
51
51
|
requirements: []
|
52
52
|
rubyforge_project:
|
53
53
|
rubygems_version: 1.8.25
|