lib/chef/application.rb in chef-0.10.8 vs lib/chef/application.rb in chef-0.10.10.beta.1
- old
+ new
@@ -1,7 +1,8 @@
#
# Author:: AJ Christensen (<aj@opscode.com>)
+# Author:: Mark Mzyk (mmzyk@opscode.com)
# Copyright:: Copyright (c) 2008 Opscode, Inc.
# License:: Apache License, Version 2.0
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
@@ -17,12 +18,14 @@
require 'socket'
require 'chef/config'
require 'chef/exceptions'
require 'chef/log'
+require 'chef/platform'
require 'mixlib/cli'
require 'tmpdir'
+require 'rbconfig'
class Chef::Application
include Mixlib::CLI
class Wakeup < Exception
@@ -37,11 +40,11 @@
trap("INT") do
Chef::Application.fatal!("SIGINT received, stopping", 2)
end
- unless RUBY_PLATFORM =~ /mswin|mingw32|windows/
+ unless Chef::Platform.windows?
trap("QUIT") do
Chef::Log.info("SIGQUIT received, call stack:\n " + caller.join("\n "))
end
trap("HUP") do
@@ -76,18 +79,21 @@
when /^(http|https):\/\//
Chef::REST.new("", nil, nil).fetch(config[:config_file]) { |f| apply_config(f.path) }
else
::File::open(config[:config_file]) { |f| apply_config(f.path) }
end
- rescue SocketError => error
- Chef::Application.fatal!("Error getting config file #{Chef::Config[:config_file]}", 2)
- rescue Exception => error
+ rescue Errno::ENOENT => error
Chef::Log.warn("*****************************************")
- Chef::Log.warn("Can not find config file: #{config[:config_file]}, using defaults.")
- Chef::Log.warn("#{error.message}")
+ Chef::Log.warn("Did not find config file: #{config[:config_file]}, using command line options.")
Chef::Log.warn("*****************************************")
Chef::Config.merge!(config)
+ rescue SocketError => error
+ Chef::Application.fatal!("Error getting config file #{Chef::Config[:config_file]}", 2)
+ rescue Chef::Exceptions::ConfigurationError => error
+ Chef::Application.fatal!("Error processing config file #{Chef::Config[:config_file]} with error #{error.message}", 2)
+ rescue Exception => error
+ Chef::Application.fatal!("Unknown error processing config file #{Chef::Config[:config_file]} with error #{error.message}", 2)
end
end
# Initialize and configure the logger. If the configured log location is not