Class: RightScale::AgentDeployer
- Includes:
- CommonParser
- Defined in:
- lib/right_agent/scripts/agent_deployer.rb
Class Method Summary collapse
-
.run ⇒ Object
Create and run deployer.
Instance Method Summary collapse
-
#deploy(options) ⇒ Object
Generate configuration from specified options and the agent’s base options and write them to a file.
-
#parse_args ⇒ Object
Create options hash from command line arguments.
Methods included from CommonParser
#agent_type, #parse_common, #resolve_identity
Class Method Details
.run ⇒ Object
Create and run deployer
Return
- true
-
Always return true
73 74 75 76 |
# File 'lib/right_agent/scripts/agent_deployer.rb', line 73 def self.run d = AgentDeployer.new d.deploy(d.parse_args) end |
Instance Method Details
#deploy(options) ⇒ Object
Generate configuration from specified options and the agent’s base options and write them to a file
Parameters
- options(Hash)
-
Command line options
Return
- true
-
Always return true
86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 |
# File 'lib/right_agent/scripts/agent_deployer.rb', line 86 def deploy() # Initialize directory settings AgentConfig.root_dir = [:root_dir] AgentConfig.cfg_dir = [:cfg_dir] AgentConfig.pid_dir = [:pid_dir] # Configure agent cfg = load_init_cfg check_agent(, cfg) cfg = configure(, cfg) # Persist configuration persist(, cfg) # Setup agent monitoring monitor() if [:monit] true end |
#parse_args ⇒ Object
Create options hash from command line arguments
Return
- options(Hash)
-
Parsed options
109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 |
# File 'lib/right_agent/scripts/agent_deployer.rb', line 109 def parse_args = {} [:agent_name] = ARGV[0] [:options] = { :secure => true } [:quiet] = false fail('No agent specified on the command line', print_usage = true) if [:agent_name].nil? opts = OptionParser.new do |opts| parse_common(opts, ) parse_other_args(opts, ) opts.on('-r', '--root-dir DIR') do |d| # Allow for more than one if [:root_dir] [:root_dir] = [[:root_dir]] unless [:root_dir].is_a?(Array) [:root_dir] << d else [:root_dir] = d end end opts.on('-c', '--cfg-dir DIR') do |d| [:cfg_dir] = d end opts.on('-z', '--pid-dir DIR') do |d| [:pid_dir] = d end opts.on('--monit') do [:monit] = true end opts.on('--http-proxy PROXY') do |proxy| [:http_proxy] = proxy end opts.on('--http-no-proxy NOPROXY') do |no_proxy| [:http_no_proxy] = no_proxy end opts.on('--time-to-live SEC') do |sec| [:time_to_live] = sec.to_i end opts.on('--retry-timeout SEC') do |sec| [:retry_timeout] = sec.to_i end opts.on('--retry-interval SEC') do |sec| [:retry_interval] = sec.to_i end opts.on('--check-interval SEC') do |sec| [:check_interval] = sec.to_i end opts.on('--ping-interval SEC') do |sec| [:ping_interval] = sec.to_i end opts.on('--reconnect-interval SEC') do |sec| [:reconnect_interval] = sec.to_i end opts.on('--grace-timeout SEC') do |sec| [:grace_timeout] = sec.to_i end opts.on('--[no-]dup-check') do |b| [:dup_check] = b end opts.on('-f', '--fiber-pool-size N') do |n| [:fiber_pool_size] = n.to_i end opts.on('--prefetch COUNT') do |count| [:prefetch] = count.to_i end opts.on("-a", "--api-url URL") do |url| [:api_url] = url end opts.on('-A', '--account ID') do |id| [:account_id] = id.to_i end opts.on('-s', '--shard ID') do |id| [:shard_id] = id.to_i end opts.on('-m', '--mode MODE') do |mode| [:mode] = mode end opts.on('-b', '--heartbeat SEC') do |sec| [:heartbeat] = sec.to_i end opts.on('--airbrake-endpoint URL') do |url| [:airbrake_endpoint] = url end opts.on('--airbrake-api-key KEY') do |key| [:airbrake_api_key] = key end opts.on('-o', '--options OPT') do |e| fail("Invalid option definition #{e}' (use '=' to separate name and value)") unless e.include?('=') key, val = e.split(/=/) [:options][key.gsub('-', '_').to_sym] = val end opts.on('-Q', '--quiet') do [:quiet] = true end opts.on_tail('--help') do puts Usage.scan(__FILE__) exit end end begin opts.parse!(ARGV) rescue Exception => e exit 0 if e.is_a?(SystemExit) fail(e., print_usage = true) end resolve_identity() end |