Class: DeployAgent::CLI
- Inherits:
-
Object
- Object
- DeployAgent::CLI
- Defined in:
- lib/deploy_agent/cli.rb
Instance Method Summary collapse
- #accesslist ⇒ Object
- #dispatch(arguments) ⇒ Object
- #restart ⇒ Object
- #run ⇒ Object
- #setup ⇒ Object
- #start ⇒ Object
- #status ⇒ Object
- #stop ⇒ Object
Instance Method Details
#accesslist ⇒ Object
68 69 70 71 72 73 74 75 76 77 78 79 80 |
# File 'lib/deploy_agent/cli.rb', line 68 def accesslist puts "Access list:" DeployAgent.allowed_destinations.each do |destination| begin IPAddr.new(destination) puts " - " + destination rescue IPAddr::InvalidAddressError puts " - " + destination + " (INVALID)" end end puts puts "To edit the list of allowed servers, please modify " + ACCESS_PATH end |
#dispatch(arguments) ⇒ Object
6 7 8 9 10 11 12 13 |
# File 'lib/deploy_agent/cli.rb', line 6 def dispatch(arguments) methods = self.public_methods(false).delete_if { |n| n == :dispatch }.sort if arguments[0] && methods.include?(arguments[0].to_sym) public_send(arguments[0]) else puts "Usage: deploy-agent [#{methods.join('|')}]" end end |
#restart ⇒ Object
19 20 21 22 23 24 25 |
# File 'lib/deploy_agent/cli.rb', line 19 def restart stop while(is_running?) sleep 0.5 end start end |
#run ⇒ Object
63 64 65 66 |
# File 'lib/deploy_agent/cli.rb', line 63 def run ensure_configured Agent.new.run end |
#setup ⇒ Object
15 16 17 |
# File 'lib/deploy_agent/cli.rb', line 15 def setup ConfigurationGenerator.new.configure end |
#start ⇒ Object
27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/deploy_agent/cli.rb', line 27 def start if is_running? puts "Deploy agent already running. Process ID #{pid_from_file}" Process.exit(1) else ensure_configured pid = fork do $background = true write_pid run end puts "Deploy agent started. Process ID #{pid}" Process.detach(pid) end end |
#status ⇒ Object
54 55 56 57 58 59 60 61 |
# File 'lib/deploy_agent/cli.rb', line 54 def status if is_running? puts "Deploy agent is running. PID #{pid_from_file}" else puts "Deploy agent is not running." Process.exit(1) end end |
#stop ⇒ Object
43 44 45 46 47 48 49 50 51 52 |
# File 'lib/deploy_agent/cli.rb', line 43 def stop if is_running? pid = pid_from_file Process.kill('TERM', pid) puts "Deploy agent stopped. Process ID #{pid}" else puts "Deploy agent is not running" Process.exit(1) end end |