murakumo 0.1.8 → 0.1.9
Sign up to get free protection for your applications and to get access to all the features.
- data/etc/murakumo.server +4 -1
- data/lib/cli/mrkmctl.rb +9 -0
- data/lib/cli/mrkmctl_options.rb +5 -2
- data/lib/cli/murakumo_options.rb +10 -1
- data/lib/misc/murakumo_const.rb +1 -1
- data/lib/srv/murakumo_health_checker.rb +4 -0
- metadata +3 -3
data/etc/murakumo.server
CHANGED
@@ -38,6 +38,9 @@ save)
|
|
38
38
|
|
39
39
|
rm -f ${conf}.new
|
40
40
|
;;
|
41
|
+
configtest)
|
42
|
+
$ctlprog -t $conf
|
43
|
+
;;
|
41
44
|
configure)
|
42
45
|
if [ -e "$conf" ]; then
|
43
46
|
echo "configuration file already exists."
|
@@ -108,6 +111,6 @@ hup)
|
|
108
111
|
fi
|
109
112
|
;;
|
110
113
|
*)
|
111
|
-
echo $"Usage: $0 {start|stop|restart|status|save|configure|hup}"
|
114
|
+
echo $"Usage: $0 {start|stop|restart|status|save|configtest|configure|hup}"
|
112
115
|
exit 1
|
113
116
|
esac
|
data/lib/cli/mrkmctl.rb
CHANGED
@@ -2,6 +2,7 @@ require 'drb/drb'
|
|
2
2
|
require 'yaml'
|
3
3
|
|
4
4
|
require 'cli/mrkmctl_options'
|
5
|
+
require 'cli/murakumo_options'
|
5
6
|
require 'misc/murakumo_const'
|
6
7
|
|
7
8
|
# オプションをパース
|
@@ -88,6 +89,14 @@ IP address TTL Priority Activity Hostname
|
|
88
89
|
n = there.clear_dead_list
|
89
90
|
puts "#{n} nodes were deleted"
|
90
91
|
|
92
|
+
# 設定のテスト
|
93
|
+
when :configtest
|
94
|
+
conf = arg.kind_of?(String) ? arg : '/etc/murakumo.yml'
|
95
|
+
ARGV.clear
|
96
|
+
ARGV.concat(['-c', conf])
|
97
|
+
murakumo_parse_args
|
98
|
+
puts 'Syntax OK'
|
99
|
+
|
91
100
|
# 設定の出力
|
92
101
|
when :yaml
|
93
102
|
puts there.to_hash.to_yaml
|
data/lib/cli/mrkmctl_options.rb
CHANGED
@@ -66,6 +66,9 @@ def mrkmctl_parse_args
|
|
66
66
|
desc 'clears a dead list'
|
67
67
|
option :clear_dead_list, '-c', '--clear-dead-list'
|
68
68
|
|
69
|
+
desc 'tests a configuration file'
|
70
|
+
option :configtest, '-t', '--configtest [PATH]'
|
71
|
+
|
69
72
|
desc 'outputs a configuration as yaml'
|
70
73
|
option :yaml, '-y', '--yaml'
|
71
74
|
|
@@ -113,11 +116,11 @@ def mrkmctl_parse_args
|
|
113
116
|
end
|
114
117
|
|
115
118
|
# command
|
116
|
-
commands = [:list, :add, :delete, :add_node, :delete_node, :get, :set, :clear_dead_list, :yaml].map {|k|
|
119
|
+
commands = [:list, :add, :delete, :add_node, :delete_node, :get, :set, :clear_dead_list, :configtest, :yaml].map {|k|
|
117
120
|
[k, options[k]]
|
118
121
|
}.select {|i| not i[1].nil? }
|
119
122
|
|
120
|
-
opt_keys = %w(-L -A -D --add-node --delete-node --get --set --clear-dead-list --yaml)
|
123
|
+
opt_keys = %w(-L -A -D --add-node --delete-node --get --set --clear-dead-list --configtest --yaml)
|
121
124
|
|
122
125
|
if commands.length < 1
|
123
126
|
parse_error('command is not specified', *opt_keys)
|
data/lib/cli/murakumo_options.rb
CHANGED
@@ -5,7 +5,9 @@ require 'socket'
|
|
5
5
|
|
6
6
|
require 'misc/murakumo_const'
|
7
7
|
|
8
|
-
Version
|
8
|
+
unless defined?(Version)
|
9
|
+
Version = Murakumo::VERSION
|
10
|
+
end
|
9
11
|
|
10
12
|
def murakumo_parse_args
|
11
13
|
optopus do
|
@@ -180,6 +182,13 @@ def murakumo_parse_args
|
|
180
182
|
if hostnames.length != hostnames.uniq.length
|
181
183
|
raise OptionParser::ParseError, 'same hostname was found'
|
182
184
|
end
|
185
|
+
|
186
|
+
# health check
|
187
|
+
if options.config_file and (health_check = options.config_file['health-check'])
|
188
|
+
unless health_check.kind_of?(Hash) and health_check.all? {|k, v| v.has_key?('script') }
|
189
|
+
raise OptionParser::ParseError, 'configuration of a health check is not right'
|
190
|
+
end
|
191
|
+
end
|
183
192
|
end
|
184
193
|
|
185
194
|
error do |e|
|
data/lib/misc/murakumo_const.rb
CHANGED
@@ -101,6 +101,10 @@ module Murakumo
|
|
101
101
|
}
|
102
102
|
rescue Timeout::Error
|
103
103
|
retval = false
|
104
|
+
rescue => e
|
105
|
+
retval = false
|
106
|
+
message = (["#{e.class}: #{e.message}"] + (e.backtrace || [])).join("\n\tfrom ")
|
107
|
+
@logger.error("healthcheck failed: #{@name}: #{message}")
|
104
108
|
end
|
105
109
|
|
106
110
|
status = retval == true ? 'good' : retval == false ? 'bad' : '-'
|
metadata
CHANGED