mysql_isolated_server 0.4.0 → 0.4.1
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.
- checksums.yaml +4 -4
- data/lib/mysql_isolated_server/version.rb +1 -1
- data/lib/mysql_isolated_server.rb +36 -20
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 67d72229d0517a98714dfc5deed145686d15615b
|
4
|
+
data.tar.gz: cdbcf4df767a442c2966f3bbca80c744d9faa8d2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5b93073f78435f66251c6798c7ff04ad48c9ff88eed4b68e72d615499470793dfc29b111cf800cd69203b44b5ae1f2888d5b321b3b68496437d5bd351f3536cc
|
7
|
+
data.tar.gz: 68d52352a2b3dc84306eece440380dc71ea8f4e616dd3b25bd50a27abe1c26a047f4bde3ed1aa1322e3614f981313ac7e6b73b2c92f3117ffc271bc41ef049cd
|
@@ -162,20 +162,14 @@ class MysqlIsolatedServer
|
|
162
162
|
end
|
163
163
|
|
164
164
|
attr_reader :pid
|
165
|
-
def
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
mysql_pid = nil
|
174
|
-
|
175
|
-
middle_pid = fork do
|
176
|
-
mysql_pid = fork do
|
177
|
-
ENV["TMPDIR"] = "#{base}/tmp"
|
178
|
-
if !@allow_output
|
165
|
+
def self.exec_wait(cmd, options = {})
|
166
|
+
allow_output = options[:allow_output] # default false
|
167
|
+
parent_pid = options[:parent_pid] || $$
|
168
|
+
|
169
|
+
fork do
|
170
|
+
exec_pid = fork do
|
171
|
+
if !allow_output
|
172
|
+
devnull = File.open("/dev/null", "w")
|
179
173
|
STDOUT.reopen(devnull)
|
180
174
|
STDERR.reopen(devnull)
|
181
175
|
end
|
@@ -188,8 +182,12 @@ class MysqlIsolatedServer
|
|
188
182
|
#
|
189
183
|
["TERM", "INT"].each do |sig|
|
190
184
|
trap(sig) do
|
191
|
-
|
192
|
-
|
185
|
+
if block_given?
|
186
|
+
yield(exec_pid)
|
187
|
+
else
|
188
|
+
Process.kill("KILL", exec_pid)
|
189
|
+
end
|
190
|
+
|
193
191
|
exit!
|
194
192
|
end
|
195
193
|
end
|
@@ -197,18 +195,36 @@ class MysqlIsolatedServer
|
|
197
195
|
while true
|
198
196
|
begin
|
199
197
|
Process.kill(0, parent_pid)
|
200
|
-
Process.kill(0,
|
198
|
+
Process.kill(0, exec_pid)
|
201
199
|
rescue Exception => e
|
202
|
-
|
203
|
-
|
200
|
+
if block_given?
|
201
|
+
yield(exec_pid)
|
202
|
+
else
|
203
|
+
Process.kill("KILL", exec_pid)
|
204
|
+
end
|
205
|
+
|
204
206
|
exit!
|
205
207
|
end
|
206
208
|
|
207
209
|
sleep 1
|
208
210
|
end
|
209
211
|
end
|
212
|
+
end
|
210
213
|
|
211
|
-
|
214
|
+
def exec_server(cmd)
|
215
|
+
cmd.strip!
|
216
|
+
cmd.gsub!(/\\\n/, ' ')
|
217
|
+
system("mkdir -p #{base}/tmp")
|
218
|
+
system("chmod 0777 #{base}/tmp")
|
219
|
+
|
220
|
+
parent_pid = @parent_pid || $$
|
221
|
+
mysql_pid = nil
|
222
|
+
|
223
|
+
ENV["TMPDIR"] = "#{base}/tmp"
|
224
|
+
@pid = MysqlIsolatedServer.exec_wait(cmd, allow_output: @allow_output, parent_pid: @parent_pid) do |mysql_pid|
|
225
|
+
Process.kill("KILL", mysql_pid)
|
226
|
+
cleanup!
|
227
|
+
end
|
212
228
|
end
|
213
229
|
|
214
230
|
def mysql_shell
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: mysql_isolated_server
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.4.
|
4
|
+
version: 0.4.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ben Osheroff
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-07-
|
11
|
+
date: 2014-07-11 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: A small library that allows you to easily spin up new local mysql servers
|
14
14
|
for testing purposes.
|