flydata 0.3.24 → 0.4.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.
- checksums.yaml +4 -4
- data/Gemfile +1 -0
- data/Gemfile.lock +3 -0
- data/VERSION +1 -1
- data/flydata.gemspec +36 -3
- data/lib/flydata.rb +8 -0
- data/lib/flydata/api/agent.rb +21 -0
- data/lib/flydata/command/helper.rb +154 -0
- data/lib/flydata/command/mysql.rb +37 -0
- data/lib/flydata/command/restart.rb +11 -0
- data/lib/flydata/command/start.rb +12 -2
- data/lib/flydata/command/status.rb +10 -0
- data/lib/flydata/command/stop.rb +10 -0
- data/lib/flydata/command/sync.rb +7 -2
- data/lib/flydata/helper/action/agent_action.rb +24 -0
- data/lib/flydata/helper/action/check_remote_actions.rb +54 -0
- data/lib/flydata/helper/action/restart_agent.rb +13 -0
- data/lib/flydata/helper/action/send_logs.rb +33 -0
- data/lib/flydata/helper/action/stop_agent.rb +13 -0
- data/lib/flydata/helper/action_ownership.rb +56 -0
- data/lib/flydata/helper/action_ownership_channel.rb +93 -0
- data/lib/flydata/helper/base_action.rb +23 -0
- data/lib/flydata/helper/config_parser.rb +197 -0
- data/lib/flydata/helper/scheduler.rb +114 -0
- data/lib/flydata/helper/server.rb +66 -0
- data/lib/flydata/helper/worker.rb +131 -0
- data/lib/flydata/output/forwarder.rb +3 -1
- data/lib/flydata/parser/mysql/dump_parser.rb +34 -19
- data/lib/flydata/sync_file_manager.rb +21 -0
- data/lib/flydata/util/file_util.rb +55 -0
- data/lib/flydata/util/shell.rb +22 -0
- data/spec/flydata/command/helper_spec.rb +121 -0
- data/spec/flydata/command/restart_spec.rb +12 -1
- data/spec/flydata/command/start_spec.rb +14 -1
- data/spec/flydata/command/stop_spec.rb +12 -1
- data/spec/flydata/helper/action/check_remote_actions_spec.rb +69 -0
- data/spec/flydata/helper/action/restart_agent_spec.rb +20 -0
- data/spec/flydata/helper/action/send_logs_spec.rb +58 -0
- data/spec/flydata/helper/action/stop_agent_spec.rb +20 -0
- data/spec/flydata/helper/action_ownership_channel_spec.rb +112 -0
- data/spec/flydata/helper/action_ownership_spec.rb +48 -0
- data/spec/flydata/helper/config_parser_spec.rb +99 -0
- data/spec/flydata/helper/helper_shared_context.rb +70 -0
- data/spec/flydata/helper/scheduler_spec.rb +35 -0
- data/spec/flydata/helper/worker_spec.rb +106 -0
- data/spec/flydata/output/forwarder_spec.rb +6 -3
- data/spec/flydata/parser/mysql/dump_parser_spec.rb +2 -1
- data/spec/flydata/util/file_util_spec.rb +110 -0
- data/spec/flydata/util/shell_spec.rb +26 -0
- data/spec/spec_helper.rb +31 -0
- metadata +46 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0c46afc6ca25cb5f8969e22aac032415a315eb0e
|
4
|
+
data.tar.gz: a95cdb85e846ae1b56f4ad3d2802fc163ec9df99
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 56cb5f8d6e58f71598bfc370ea31a24784c1132b5fcadbae263cb29c85a1cd950ff0c2169698722f73058c9d44b16424a57d441c4b98f1ee914ddd57062d91df
|
7
|
+
data.tar.gz: c0b6985cafa887eb2a8aac272c57431f1bb72343b937be7ebb55ef5dfdfec989778acf160119bd0205e4978289fd4134c04890a468bc655022dc99d17f65107f
|
data/Gemfile
CHANGED
@@ -14,6 +14,7 @@ gem "treetop", '~> 1.5', '>= 1.5.3'
|
|
14
14
|
gem "sys-filesystem", '~> 1.1', '>= 1.1.3'
|
15
15
|
gem "io-console", '~> 0.4.2', '>= 0.4.2'
|
16
16
|
gem "kodama", '~> 0.1.2', '>= 0.1.5'
|
17
|
+
gem "serverengine", '~> 1.5'
|
17
18
|
|
18
19
|
group :development do
|
19
20
|
gem "jeweler", '~> 1.8', '>= 1.8.8'
|
data/Gemfile.lock
CHANGED
@@ -107,6 +107,8 @@ GEM
|
|
107
107
|
rspec-support (3.0.3)
|
108
108
|
ruby-binlog (1.0.4)
|
109
109
|
ruby-prof (0.15.1)
|
110
|
+
serverengine (1.5.10)
|
111
|
+
sigdump (~> 0.2.2)
|
110
112
|
sigdump (0.2.2)
|
111
113
|
slop (3.6.0)
|
112
114
|
sqlite3 (1.3.9)
|
@@ -140,6 +142,7 @@ DEPENDENCIES
|
|
140
142
|
rest-client (~> 1.6, >= 1.6.7)
|
141
143
|
rspec (~> 3.0)
|
142
144
|
ruby-prof (~> 0.15, >= 0.15.1)
|
145
|
+
serverengine (~> 1.5)
|
143
146
|
slop (~> 3.4, >= 3.4.6)
|
144
147
|
sqlite3 (~> 1.3, >= 1.3.9)
|
145
148
|
sys-filesystem (~> 1.1, >= 1.1.3)
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.
|
1
|
+
0.4.0
|
data/flydata.gemspec
CHANGED
@@ -2,16 +2,16 @@
|
|
2
2
|
# DO NOT EDIT THIS FILE DIRECTLY
|
3
3
|
# Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
|
4
4
|
# -*- encoding: utf-8 -*-
|
5
|
-
# stub: flydata 0.
|
5
|
+
# stub: flydata 0.4.0 ruby lib
|
6
6
|
|
7
7
|
Gem::Specification.new do |s|
|
8
8
|
s.name = "flydata"
|
9
|
-
s.version = "0.
|
9
|
+
s.version = "0.4.0"
|
10
10
|
|
11
11
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
12
12
|
s.require_paths = ["lib"]
|
13
13
|
s.authors = ["Koichi Fujikawa", "Masashi Miyazaki", "Matthew Luu", "Mak Inada", "Sriram NS"]
|
14
|
-
s.date = "2015-06-
|
14
|
+
s.date = "2015-06-17"
|
15
15
|
s.description = "FlyData Agent"
|
16
16
|
s.email = "sysadmin@flydata.com"
|
17
17
|
s.executables = ["fdmysqldump", "flydata", "serverinfo"]
|
@@ -81,6 +81,7 @@ Gem::Specification.new do |s|
|
|
81
81
|
"flydata.gemspec",
|
82
82
|
"lib/fly_data_model.rb",
|
83
83
|
"lib/flydata.rb",
|
84
|
+
"lib/flydata/api/agent.rb",
|
84
85
|
"lib/flydata/api/base.rb",
|
85
86
|
"lib/flydata/api/data_entry.rb",
|
86
87
|
"lib/flydata/api/data_port.rb",
|
@@ -91,8 +92,10 @@ Gem::Specification.new do |s|
|
|
91
92
|
"lib/flydata/command/conf.rb",
|
92
93
|
"lib/flydata/command/crontab.rb",
|
93
94
|
"lib/flydata/command/encrypt.rb",
|
95
|
+
"lib/flydata/command/helper.rb",
|
94
96
|
"lib/flydata/command/kill_all.rb",
|
95
97
|
"lib/flydata/command/login.rb",
|
98
|
+
"lib/flydata/command/mysql.rb",
|
96
99
|
"lib/flydata/command/restart.rb",
|
97
100
|
"lib/flydata/command/routine.rb",
|
98
101
|
"lib/flydata/command/sender.rb",
|
@@ -124,6 +127,18 @@ Gem::Specification.new do |s|
|
|
124
127
|
"lib/flydata/fluent-plugins/out_forward_ssl.rb",
|
125
128
|
"lib/flydata/fluent-plugins/preference.rb",
|
126
129
|
"lib/flydata/flydata_crontab.sh",
|
130
|
+
"lib/flydata/helper/action/agent_action.rb",
|
131
|
+
"lib/flydata/helper/action/check_remote_actions.rb",
|
132
|
+
"lib/flydata/helper/action/restart_agent.rb",
|
133
|
+
"lib/flydata/helper/action/send_logs.rb",
|
134
|
+
"lib/flydata/helper/action/stop_agent.rb",
|
135
|
+
"lib/flydata/helper/action_ownership.rb",
|
136
|
+
"lib/flydata/helper/action_ownership_channel.rb",
|
137
|
+
"lib/flydata/helper/base_action.rb",
|
138
|
+
"lib/flydata/helper/config_parser.rb",
|
139
|
+
"lib/flydata/helper/scheduler.rb",
|
140
|
+
"lib/flydata/helper/server.rb",
|
141
|
+
"lib/flydata/helper/worker.rb",
|
127
142
|
"lib/flydata/helpers.rb",
|
128
143
|
"lib/flydata/heroku.rb",
|
129
144
|
"lib/flydata/heroku/configuration_methods.rb",
|
@@ -140,6 +155,8 @@ Gem::Specification.new do |s|
|
|
140
155
|
"lib/flydata/proxy.rb",
|
141
156
|
"lib/flydata/sync_file_manager.rb",
|
142
157
|
"lib/flydata/util/encryptor.rb",
|
158
|
+
"lib/flydata/util/file_util.rb",
|
159
|
+
"lib/flydata/util/shell.rb",
|
143
160
|
"spec/fluent_plugins_spec_helper.rb",
|
144
161
|
"spec/fly_data_model_spec.rb",
|
145
162
|
"spec/flydata/api/data_entry_spec.rb",
|
@@ -149,6 +166,7 @@ Gem::Specification.new do |s|
|
|
149
166
|
"spec/flydata/command/conf_spec.rb",
|
150
167
|
"spec/flydata/command/crontab_spec.rb",
|
151
168
|
"spec/flydata/command/encrypt_spec.rb",
|
169
|
+
"spec/flydata/command/helper_spec.rb",
|
152
170
|
"spec/flydata/command/kill_all_spec.rb",
|
153
171
|
"spec/flydata/command/login_spec.rb",
|
154
172
|
"spec/flydata/command/restart_spec.rb",
|
@@ -171,6 +189,16 @@ Gem::Specification.new do |s|
|
|
171
189
|
"spec/flydata/fluent-plugins/mysql/shared_query_handler_context.rb",
|
172
190
|
"spec/flydata/fluent-plugins/mysql/table_meta_spec.rb",
|
173
191
|
"spec/flydata/fluent-plugins/mysql/truncate_query_handler_spec.rb",
|
192
|
+
"spec/flydata/helper/action/check_remote_actions_spec.rb",
|
193
|
+
"spec/flydata/helper/action/restart_agent_spec.rb",
|
194
|
+
"spec/flydata/helper/action/send_logs_spec.rb",
|
195
|
+
"spec/flydata/helper/action/stop_agent_spec.rb",
|
196
|
+
"spec/flydata/helper/action_ownership_channel_spec.rb",
|
197
|
+
"spec/flydata/helper/action_ownership_spec.rb",
|
198
|
+
"spec/flydata/helper/config_parser_spec.rb",
|
199
|
+
"spec/flydata/helper/helper_shared_context.rb",
|
200
|
+
"spec/flydata/helper/scheduler_spec.rb",
|
201
|
+
"spec/flydata/helper/worker_spec.rb",
|
174
202
|
"spec/flydata/heroku_spec.rb",
|
175
203
|
"spec/flydata/mysql/binlog_position_spec.rb",
|
176
204
|
"spec/flydata/mysql/mysql_util_spec.rb",
|
@@ -180,6 +208,8 @@ Gem::Specification.new do |s|
|
|
180
208
|
"spec/flydata/parser/mysql/dump_parser_spec.rb",
|
181
209
|
"spec/flydata/sync_file_manager_spec.rb",
|
182
210
|
"spec/flydata/util/encryptor_spec.rb",
|
211
|
+
"spec/flydata/util/file_util_spec.rb",
|
212
|
+
"spec/flydata/util/shell_spec.rb",
|
183
213
|
"spec/flydata_spec.rb",
|
184
214
|
"spec/spec_helper.rb",
|
185
215
|
"tmpl/redshift_mysql_data_entry.conf.tmpl"
|
@@ -206,6 +236,7 @@ Gem::Specification.new do |s|
|
|
206
236
|
s.add_runtime_dependency(%q<sys-filesystem>, [">= 1.1.3", "~> 1.1"])
|
207
237
|
s.add_runtime_dependency(%q<io-console>, [">= 0.4.2", "~> 0.4.2"])
|
208
238
|
s.add_runtime_dependency(%q<kodama>, [">= 0.1.5", "~> 0.1.2"])
|
239
|
+
s.add_runtime_dependency(%q<serverengine>, ["~> 1.5"])
|
209
240
|
s.add_development_dependency(%q<jeweler>, [">= 1.8.8", "~> 1.8"])
|
210
241
|
s.add_development_dependency(%q<rspec>, ["~> 3.0"])
|
211
242
|
s.add_development_dependency(%q<timecop>, [">= 0.7.1", "~> 0.7"])
|
@@ -229,6 +260,7 @@ Gem::Specification.new do |s|
|
|
229
260
|
s.add_dependency(%q<sys-filesystem>, [">= 1.1.3", "~> 1.1"])
|
230
261
|
s.add_dependency(%q<io-console>, [">= 0.4.2", "~> 0.4.2"])
|
231
262
|
s.add_dependency(%q<kodama>, [">= 0.1.5", "~> 0.1.2"])
|
263
|
+
s.add_dependency(%q<serverengine>, ["~> 1.5"])
|
232
264
|
s.add_dependency(%q<jeweler>, [">= 1.8.8", "~> 1.8"])
|
233
265
|
s.add_dependency(%q<rspec>, ["~> 3.0"])
|
234
266
|
s.add_dependency(%q<timecop>, [">= 0.7.1", "~> 0.7"])
|
@@ -253,6 +285,7 @@ Gem::Specification.new do |s|
|
|
253
285
|
s.add_dependency(%q<sys-filesystem>, [">= 1.1.3", "~> 1.1"])
|
254
286
|
s.add_dependency(%q<io-console>, [">= 0.4.2", "~> 0.4.2"])
|
255
287
|
s.add_dependency(%q<kodama>, [">= 0.1.5", "~> 0.1.2"])
|
288
|
+
s.add_dependency(%q<serverengine>, ["~> 1.5"])
|
256
289
|
s.add_dependency(%q<jeweler>, [">= 1.8.8", "~> 1.8"])
|
257
290
|
s.add_dependency(%q<rspec>, ["~> 3.0"])
|
258
291
|
s.add_dependency(%q<timecop>, [">= 0.7.1", "~> 0.7"])
|
data/lib/flydata.rb
CHANGED
@@ -29,7 +29,15 @@ module Flydata
|
|
29
29
|
FLYDATA_SERVERINFO = File.join(FLYDATA_GEM_BIN, 'serverinfo')
|
30
30
|
FLYDATA_LOG = File.join(FLYDATA_HOME, 'flydata.log')
|
31
31
|
FLYDATA_CONF = File.join(FLYDATA_HOME, 'flydata.conf')
|
32
|
+
FLYDATA_HELPER_HOME = File.join(FLYDATA_HOME, 'helper')
|
32
33
|
|
33
34
|
VERSION_PATH = File.join(FLYDATA_GEM_HOME, 'VERSION')
|
34
35
|
include Flydata::Heroku
|
35
36
|
end
|
37
|
+
|
38
|
+
# Require all helper files -
|
39
|
+
# TODO : Check if this should be moved else where or can be more generic (not just helper files)
|
40
|
+
lib_dir = File.dirname(File.absolute_path(__FILE__))
|
41
|
+
FileUtils.cd(lib_dir) do
|
42
|
+
Dir["flydata/helper/**/*.rb"].each { |file| require file }
|
43
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
require 'flydata/api/base'
|
2
|
+
|
3
|
+
module Flydata
|
4
|
+
module Api
|
5
|
+
class Agent < Base
|
6
|
+
def initialize(api_client)
|
7
|
+
@model_name = 'agent'
|
8
|
+
@url_path = "/#{@model_name}"
|
9
|
+
super
|
10
|
+
end
|
11
|
+
|
12
|
+
def actions(last_id)
|
13
|
+
@client.get("#{@url_path}/actions?last_id=#{last_id}")
|
14
|
+
end
|
15
|
+
|
16
|
+
def send_logs(action_id, logs)
|
17
|
+
@client.post("#{@url_path}/logs", nil, {action_id: action_id, logs: logs})
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,154 @@
|
|
1
|
+
require 'flydata/command/base'
|
2
|
+
require 'flydata/helper/server'
|
3
|
+
require 'flydata/helper/config_parser'
|
4
|
+
require 'flydata/util/shell'
|
5
|
+
|
6
|
+
module Flydata
|
7
|
+
module Command
|
8
|
+
class Helper < Base
|
9
|
+
|
10
|
+
DEFAULT_OPTIONS = {
|
11
|
+
#daemon
|
12
|
+
daemonize: false,
|
13
|
+
supervisor: true,
|
14
|
+
workers: 2,
|
15
|
+
|
16
|
+
#logger
|
17
|
+
log: nil,
|
18
|
+
log_level: 'info',
|
19
|
+
log_rotate_age: 10,
|
20
|
+
log_rotate_size: 10*1024*1024
|
21
|
+
}
|
22
|
+
|
23
|
+
def self.slop_start
|
24
|
+
Slop.new do
|
25
|
+
on 'c=', 'config=','config file path'
|
26
|
+
on 'n', 'no-daemon', 'Start Helper as a regular program'
|
27
|
+
on 'l=', 'log=', 'log file path'
|
28
|
+
on 'e=', 'level=', 'log level'
|
29
|
+
on 'r=', 'rotate=', 'Number of times logs are rotated before being removed'
|
30
|
+
on 's=', 'size=', 'Size (in bytes) after which log is rotated'
|
31
|
+
#For now, size needs to be specified in bytes (dont think it will be used often)
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
def initialize(options = Slop.new)
|
36
|
+
super
|
37
|
+
@helper_config = Flydata::Helper::ConfigParser.parse_file(opts[:config])[:helper]
|
38
|
+
create_helper_dirs
|
39
|
+
end
|
40
|
+
|
41
|
+
def start
|
42
|
+
if running?
|
43
|
+
log_info_stdout("Helper is already running.")
|
44
|
+
else
|
45
|
+
raw_start
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
def stop
|
50
|
+
if running?
|
51
|
+
log_info_stdout("Stopping Helper.")
|
52
|
+
run_command(stop_cmd)
|
53
|
+
else
|
54
|
+
log_info_stdout("Helper is not running.")
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
58
|
+
def status
|
59
|
+
if running?
|
60
|
+
log_info_stdout("Helper is running.")
|
61
|
+
else
|
62
|
+
log_info_stdout("Helper is not running.")
|
63
|
+
end
|
64
|
+
end
|
65
|
+
|
66
|
+
def restart
|
67
|
+
if running?
|
68
|
+
log_info_stdout("Restarting Helper.")
|
69
|
+
run_command(kill_hup_cmd)
|
70
|
+
else
|
71
|
+
raw_start
|
72
|
+
end
|
73
|
+
end
|
74
|
+
|
75
|
+
private
|
76
|
+
|
77
|
+
def create_config_with_args
|
78
|
+
Hash.new.tap do |c|
|
79
|
+
c[:config_path] = opts[:config]
|
80
|
+
c[:log] = opts[:log] ? opts[:log] : @helper_config.helper_log_path
|
81
|
+
unless opts.no_daemon?
|
82
|
+
c[:pid_path] = @helper_config.helper_pid_path
|
83
|
+
c[:daemonize] = true
|
84
|
+
end
|
85
|
+
c[:log_level] = opts[:level] if opts[:level]
|
86
|
+
c[:log_rotate_age] = opts[:rotate].to_i if opts[:rotate]
|
87
|
+
c[:log_rotate_size] = opts[:size].to_i if opts[:size]
|
88
|
+
end
|
89
|
+
end
|
90
|
+
|
91
|
+
def run_command(cmd)
|
92
|
+
o, e, s = Util::Shell.run_cmd(cmd)
|
93
|
+
log_error_stderr(e) if not e.to_s.empty?
|
94
|
+
success = (s.to_i == 0)
|
95
|
+
if success
|
96
|
+
log_info_stdout("Done")
|
97
|
+
else
|
98
|
+
log_error_stderr("Failed")
|
99
|
+
end
|
100
|
+
success
|
101
|
+
end
|
102
|
+
|
103
|
+
def running?
|
104
|
+
`#{running_cmd}`.to_i > 0
|
105
|
+
end
|
106
|
+
|
107
|
+
def stop_cmd
|
108
|
+
<<EOS
|
109
|
+
if #{running_cmd}; then
|
110
|
+
#{kill_cmd}
|
111
|
+
i=0
|
112
|
+
while #{running_cmd}; do
|
113
|
+
sleep 1.0
|
114
|
+
if [ $i -gt 10 ]; then # 10sec
|
115
|
+
echo "Timeout warning: It failed to stop within 10 seconds. The process will be killed with SIGKILL."
|
116
|
+
kill -9 -$(ps --pid `#{@helper_config.helper_pid_path}` --no-heading -o "%r" | tr -d ' ')
|
117
|
+
else
|
118
|
+
i=`expr $i + 1`
|
119
|
+
fi
|
120
|
+
done
|
121
|
+
rm #{@helper_config.helper_pid_path}
|
122
|
+
fi
|
123
|
+
EOS
|
124
|
+
end
|
125
|
+
|
126
|
+
def running_cmd
|
127
|
+
"[ -f #{@helper_config.helper_pid_path} ] && pgrep -P \`cat #{@helper_config.helper_pid_path}\`"
|
128
|
+
end
|
129
|
+
|
130
|
+
def kill_hup_cmd
|
131
|
+
kill_cmd("-HUP")
|
132
|
+
end
|
133
|
+
|
134
|
+
def kill_cmd(option = nil)
|
135
|
+
"kill #{option} \`cat #{@helper_config.helper_pid_path}\`"
|
136
|
+
end
|
137
|
+
|
138
|
+
def raw_start
|
139
|
+
log_info_stdout("Starting Helper.")
|
140
|
+
Flydata::Helper::Server.run(
|
141
|
+
DEFAULT_OPTIONS.merge(create_config_with_args))
|
142
|
+
log_info_stdout("Done")
|
143
|
+
end
|
144
|
+
|
145
|
+
def create_helper_dirs
|
146
|
+
#Create helper dirs if they don't exist
|
147
|
+
FileUtils.mkdir_p([@helper_config.helper_home,
|
148
|
+
@helper_config.helper_pid_dir,
|
149
|
+
@helper_config.helper_position_dir
|
150
|
+
])
|
151
|
+
end
|
152
|
+
end
|
153
|
+
end
|
154
|
+
end
|
@@ -0,0 +1,37 @@
|
|
1
|
+
require 'open3'
|
2
|
+
require 'flydata/command/sync'
|
3
|
+
|
4
|
+
module Flydata
|
5
|
+
module Command
|
6
|
+
|
7
|
+
class Mysql < Sync
|
8
|
+
def run
|
9
|
+
de = retrieve_sync_data_entry
|
10
|
+
de['mysql_data_entry_preference'].delete('tables')
|
11
|
+
cmd = Flydata::Mysql::MysqlUtil::generate_mysql_cmd(de['mysql_data_entry_preference'])
|
12
|
+
if $stdin.tty?
|
13
|
+
# interactive shell
|
14
|
+
system cmd
|
15
|
+
else
|
16
|
+
# execute queries given to $stdin
|
17
|
+
Open3.popen2e(cmd) do |i, o, wt|
|
18
|
+
$stdin.each_line do |line|
|
19
|
+
i.print line
|
20
|
+
end
|
21
|
+
i.close
|
22
|
+
while line = o.gets
|
23
|
+
print line
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
def flush; end
|
30
|
+
def reset; end
|
31
|
+
def skip; end
|
32
|
+
def generate_table_ddl; end
|
33
|
+
def fix_binlogpos; end
|
34
|
+
end
|
35
|
+
|
36
|
+
end
|
37
|
+
end
|
@@ -1,12 +1,23 @@
|
|
1
1
|
require 'flydata/command/base'
|
2
2
|
require 'flydata/command/sender'
|
3
|
+
require 'flydata/command/helper'
|
3
4
|
|
4
5
|
module Flydata
|
5
6
|
module Command
|
6
7
|
class Restart < Base
|
8
|
+
def self.slop
|
9
|
+
Slop.new do
|
10
|
+
on 'skip-helper', 'Skip restarting the Helper'
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
7
14
|
def run
|
8
15
|
sender = Flydata::Command::Sender.new
|
9
16
|
sender.restart
|
17
|
+
unless opts.skip_helper?
|
18
|
+
helper = Flydata::Command::Helper.new
|
19
|
+
helper.restart
|
20
|
+
end
|
10
21
|
end
|
11
22
|
end
|
12
23
|
end
|
@@ -1,15 +1,25 @@
|
|
1
1
|
require 'flydata/command/base'
|
2
2
|
require 'flydata/command/sender'
|
3
|
+
require 'flydata/command/helper'
|
3
4
|
|
4
5
|
module Flydata
|
5
6
|
module Command
|
6
7
|
class Start < Base
|
7
8
|
def self.slop
|
8
|
-
Flydata::Command::Sender.slop_start # Needs options for Sender#start
|
9
|
+
sender_opts = Flydata::Command::Sender.slop_start # Needs options for Sender#start
|
10
|
+
sender_opts.on 'skip-helper', 'Skip starting the Helper'
|
11
|
+
sender_opts
|
9
12
|
end
|
10
|
-
def run
|
13
|
+
def run(*args)
|
11
14
|
sender = Flydata::Command::Sender.new(opts)
|
12
15
|
sender.start
|
16
|
+
unless opts.skip_helper?
|
17
|
+
helper_opts = Flydata::Command::Helper.slop_start
|
18
|
+
helper_opts.parse!(args)
|
19
|
+
helper = Flydata::Command::Helper.new(helper_opts)
|
20
|
+
helper.stop # kill existing helper process (if any) and start
|
21
|
+
helper.start
|
22
|
+
end
|
13
23
|
end
|
14
24
|
end
|
15
25
|
end
|