Class: PushyClient::CLI
- Inherits:
-
Chef::Application
- Object
- Chef::Application
- PushyClient::CLI
- Defined in:
- lib/pushy_client/cli.rb
Class Method Summary collapse
Instance Method Summary collapse
- #reconfigure ⇒ Object
- #run_application ⇒ Object
- #setup_application ⇒ Object
- #shutdown(ret_code = 0) ⇒ Object
Class Method Details
.find_default_config ⇒ Object
30 31 32 33 34 35 36 37 38 |
# File 'lib/pushy_client/cli.rb', line 30 def self.find_default_config configs = ['chef-push-client.rb', 'push-jobs-client.rb', 'client.rb'] base = "/etc/chef" paths = configs.map {|c| Chef::Config.platform_specific_path(File.join(base, c)) } path = paths.detect {|p| File.exist?(p) } # todo make debug before commit Chef::Log.info("Push Client using default config file path: '#{path}'") path end |
Instance Method Details
#reconfigure ⇒ Object
105 106 107 108 109 |
# File 'lib/pushy_client/cli.rb', line 105 def reconfigure # We do not use Chef's formatters. Chef::Config[:force_logger] = true super end |
#run_application ⇒ Object
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 |
# File 'lib/pushy_client/cli.rb', line 119 def run_application if Chef::Config[:version] puts "Push Client version: #{::PushyClient::VERSION}" end ohai = Ohai::System.new ohai.load_plugins ohai.run_plugins(true, ['hostname']) @client = PushyClient.new( :chef_server_url => Chef::Config[:chef_server_url], :client_key => Chef::Config[:client_key], :node_name => Chef::Config[:node_name] || ohai[:fqdn] || ohai[:hostname], :whitelist => Chef::Config[:whitelist] || { 'chef-client' => 'chef-client' }, :hostname => ohai[:hostname], :filedir => Chef::Config[:file_dir], :allow_unencrypted => Chef::Config[:allow_unencrypted], :allowed_overwritable_env_vars => Chef::Config[:allowed_overwritable_env_vars] ) @client.start # install signal handlers # Windows does not support QUIT and USR1 signals exit_signals = if Chef::Platform.windows? ["TERM", "INT"] else ["TERM", "QUIT", "INT"] end exit_signals.each do |sig| Signal.trap(sig) do puts "received #{sig}, shutting down" shutdown(0) end end unless Chef::Platform.windows? Signal.trap("USR1") do puts "received USR1, reconfiguring" @client.trigger_reconfigure end end # Block forever so that client threads can run while true sleep 3600 end end |
#setup_application ⇒ Object
111 112 |
# File 'lib/pushy_client/cli.rb', line 111 def setup_application end |
#shutdown(ret_code = 0) ⇒ Object
114 115 116 117 |
# File 'lib/pushy_client/cli.rb', line 114 def shutdown(ret_code = 0) @client.stop if @client exit(ret_code) end |