auto-consul 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.
Files changed (2) hide show
  1. data/bin/auto-consul +37 -1
  2. metadata +9 -9
data/bin/auto-consul CHANGED
@@ -11,6 +11,15 @@ class UnknownCommandException < Exception
11
11
  end
12
12
 
13
13
  class Command < OpenStruct
14
+ HELP = {
15
+ "set_mode" => "Dynamically determines the mode from the registry and parameters, and sets it (for next startup).",
16
+ "set_server" => "Sets the mode (for next startup) to server.",
17
+ "set_agent" => "Sets the mode (for next startup) to agent.",
18
+ "run" => "Runs consul agent, dynamically determining the mode, with heartbeat if appropriate.",
19
+ "direct_run" => "Runs consul agent, with no mode determination, with heartbeat if appropriate.",
20
+ "heartbeat" => "Runs heartbeat process, ticking to the registry at specified interval",
21
+ }
22
+
14
23
  def local
15
24
  @local ||= AutoConsul::Local.bind_to_path(data_dir)
16
25
  end
@@ -31,6 +40,18 @@ class Command < OpenStruct
31
40
  end
32
41
  end
33
42
 
43
+ def do_set_server
44
+ puts "Setting to server mode."
45
+ local.set_server!
46
+ 0
47
+ end
48
+
49
+ def do_set_agent
50
+ puts "Setting to agent mode."
51
+ local.set_agent!
52
+ 0
53
+ end
54
+
34
55
  def do_set_mode
35
56
  cluster.set_mode! local, expiry, servers
36
57
  # Healthy exit
@@ -82,6 +103,13 @@ class Command < OpenStruct
82
103
  end
83
104
  end
84
105
 
106
+ def self.commands
107
+ cmds = instance_methods.collect {|m| m.to_s}.find_all {|m| m[0..2] == 'do_'}.collect {|n| n[3..-1]}
108
+ cmds.collect do |name|
109
+ [name, HELP[name] || '']
110
+ end
111
+ end
112
+
85
113
  def execute cmd
86
114
  command = "do_#{cmd}".to_sym
87
115
  if respond_to? command
@@ -142,10 +170,18 @@ parser = OptionParser.new do |opts|
142
170
  runner.servers = s.to_i
143
171
  end
144
172
 
145
- opts.on_tail('-h', '--help', "Show this help message.") do
173
+ opts.on('-h', '--help', "Show this help message.") do
146
174
  puts opts
147
175
  exit
148
176
  end
177
+
178
+ opts.separator ''
179
+ opts.separator 'Commands:'
180
+ Command.commands.sort.each do |name, help|
181
+ opts.separator ''
182
+ opts.separator " #{name}"
183
+ opts.separator " #{help}" if help.size > 0
184
+ end
149
185
  end
150
186
 
151
187
  parser.parse!
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: auto-consul
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3
4
+ version: 0.1.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -83,22 +83,22 @@ extensions: []
83
83
  extra_rdoc_files: []
84
84
  files:
85
85
  - lib/auto-consul.rb
86
+ - lib/auto-consul/cluster.rb
87
+ - lib/auto-consul/local.rb
86
88
  - lib/auto-consul/runner.rb
89
+ - lib/auto-consul/run_state.rb
87
90
  - lib/auto-consul/providers/s3.rb
88
91
  - lib/auto-consul/run_state/cli.rb
89
- - lib/auto-consul/cluster.rb
90
- - lib/auto-consul/run_state.rb
91
- - lib/auto-consul/local.rb
92
- - spec/local_state_spec.rb
92
+ - spec/spec-helper.rb
93
93
  - spec/s3_registry_provider_spec.rb
94
94
  - spec/cluster_spec.rb
95
95
  - spec/runner_spec.rb
96
+ - spec/local_state_spec.rb
96
97
  - spec/run_state_cli_provider_spec.rb
97
- - spec/spec-helper.rb
98
98
  - bin/auto-consul
99
- - Gemfile.lock
100
- - README.md
101
99
  - Gemfile
100
+ - README.md
101
+ - Gemfile.lock
102
102
  - LICENSE
103
103
  homepage:
104
104
  licenses:
@@ -121,7 +121,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
121
121
  version: '0'
122
122
  requirements: []
123
123
  rubyforge_project:
124
- rubygems_version: 1.8.25
124
+ rubygems_version: 1.8.23
125
125
  signing_key:
126
126
  specification_version: 3
127
127
  summary: Ruby utilities to aid in the bootstrapping of EC2-based consul clusters