mysql_isolated_server 0.0.3 → 0.1.0
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 +23 -10
- metadata +3 -3
@@ -47,6 +47,26 @@ class MysqlIsolatedServer
|
|
47
47
|
output.split("\n").first
|
48
48
|
end
|
49
49
|
|
50
|
+
def up!
|
51
|
+
exec_server <<-EOL
|
52
|
+
mysqld --no-defaults --default-storage-engine=innodb \
|
53
|
+
--datadir=#{@mysql_data_dir} --pid-file=#{@base}/mysqld.pid --port=#{@port} \
|
54
|
+
#{@params} --socket=#{@mysql_data_dir}/mysql.sock --log-bin --log-slave-updates
|
55
|
+
EOL
|
56
|
+
|
57
|
+
while !system("mysql -h127.0.0.1 --port=#{@port} --database=mysql -u root -e 'select 1' >/dev/null 2>&1")
|
58
|
+
sleep(0.1)
|
59
|
+
end
|
60
|
+
end
|
61
|
+
|
62
|
+
def down!
|
63
|
+
Process.kill("TERM", @pid)
|
64
|
+
while (Process.kill 0, @pid rescue false)
|
65
|
+
sleep 1
|
66
|
+
end
|
67
|
+
@cx = nil
|
68
|
+
end
|
69
|
+
|
50
70
|
def boot!
|
51
71
|
@port ||= grab_free_port
|
52
72
|
system("rm -Rf #{@mysql_data_dir}")
|
@@ -61,15 +81,7 @@ class MysqlIsolatedServer
|
|
61
81
|
system("cp #{File.expand_path(File.dirname(__FILE__))}/tables/user.* #{@mysql_data_dir}/mysql")
|
62
82
|
end
|
63
83
|
|
64
|
-
|
65
|
-
mysqld --no-defaults --default-storage-engine=innodb \
|
66
|
-
--datadir=#{@mysql_data_dir} --pid-file=#{@base}/mysqld.pid --port=#{@port} \
|
67
|
-
#{@params} --socket=#{@mysql_data_dir}/mysql.sock --log-bin --log-slave-updates
|
68
|
-
EOL
|
69
|
-
|
70
|
-
while !system("mysql -h127.0.0.1 --port=#{@port} --database=mysql -u root -e 'select 1' >/dev/null 2>&1")
|
71
|
-
sleep(0.1)
|
72
|
-
end
|
84
|
+
up!
|
73
85
|
|
74
86
|
tzinfo_to_sql = locate_executable("mysql_tzinfo_to_sql5", "mysql_tzinfo_to_sql")
|
75
87
|
raise "could not find mysql_tzinfo_to_sql" unless tzinfo_to_sql
|
@@ -109,8 +121,9 @@ class MysqlIsolatedServer
|
|
109
121
|
|
110
122
|
exec(cmd)
|
111
123
|
end
|
124
|
+
Thread.new { Process.wait(pid) }
|
112
125
|
at_exit {
|
113
|
-
Process.kill("TERM", pid)
|
126
|
+
Process.kill("TERM", pid) rescue nil
|
114
127
|
system("rm -Rf #{base}")
|
115
128
|
}
|
116
129
|
@pid = pid
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: mysql_isolated_server
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0
|
4
|
+
version: 0.1.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-04-
|
12
|
+
date: 2013-04-23 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.
|
@@ -50,7 +50,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
50
50
|
version: '0'
|
51
51
|
requirements: []
|
52
52
|
rubyforge_project:
|
53
|
-
rubygems_version: 1.8.
|
53
|
+
rubygems_version: 1.8.25
|
54
54
|
signing_key:
|
55
55
|
specification_version: 3
|
56
56
|
summary: A small library that allows you to easily spin up new local mysql servers
|