summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKartik Null Cating-Subramanian <ksubramanian@chef.io>2015-07-14 11:02:43 -0400
committerKartik Null Cating-Subramanian <ksubramanian@chef.io>2015-07-20 12:23:42 -0400
commitde5fd05da851af01e960266feda9ce74b03e9bc6 (patch)
tree2e93ef26f4b1148205b674a9fae2ea6f7c101c6f
parent0b0dd4040bc8ca485b90b58a65884645b389c8e5 (diff)
downloadchef-de5fd05da851af01e960266feda9ce74b03e9bc6.tar.gz
Add flag to windows_service_manager to delay start.
-rwxr-xr-xbin/chef-service-manager3
-rw-r--r--lib/chef/application/windows_service_manager.rb29
2 files changed, 19 insertions, 13 deletions
diff --git a/bin/chef-service-manager b/bin/chef-service-manager
index 7cef10f506..bbcab5ca92 100755
--- a/bin/chef-service-manager
+++ b/bin/chef-service-manager
@@ -28,7 +28,8 @@ if Chef::Platform.windows?
:service_name => "chef-client",
:service_display_name => "Chef Client Service",
:service_description => "Runs Chef Client on regular, configurable intervals.",
- :service_file_path => File.expand_path(File.join(File.dirname(__FILE__), '../../../../bin/chef-windows-service'))
+ :service_file_path => File.expand_path(File.join(File.dirname(__FILE__), '../../../../bin/chef-windows-service')),
+ :delayed_start => true
}
Chef::Application::WindowsServiceManager.new(chef_client_service).run
else
diff --git a/lib/chef/application/windows_service_manager.rb b/lib/chef/application/windows_service_manager.rb
index de8ed657c2..97db7ee56f 100644
--- a/lib/chef/application/windows_service_manager.rb
+++ b/lib/chef/application/windows_service_manager.rb
@@ -78,7 +78,7 @@ class Chef
raise ArgumentError, "Service definition is not provided" if service_options.nil?
- required_options = [:service_name, :service_display_name, :service_name, :service_description, :service_file_path]
+ required_options = [:service_name, :service_display_name, :service_description, :service_file_path]
required_options.each do |req_option|
if !service_options.has_key?(req_option)
@@ -92,6 +92,7 @@ class Chef
@service_file_path = service_options[:service_file_path]
@service_start_name = service_options[:run_as_user]
@password = service_options[:run_as_password]
+ @delayed_start = service_options[:delayed_start]
end
def run(params = ARGV)
@@ -113,17 +114,21 @@ class Chef
cmd = "\"#{ruby}\" \"#{@service_file_path}\" #{opts}".gsub(File::SEPARATOR, File::ALT_SEPARATOR)
::Win32::Service.new(
- :service_name => @service_name,
- :display_name => @service_display_name,
- :description => @service_description,
- # Prior to 0.8.5, win32-service creates interactive services by default,
- # and we don't want that, so we need to override the service type.
- :service_type => ::Win32::Service::SERVICE_WIN32_OWN_PROCESS,
- :start_type => ::Win32::Service::SERVICE_AUTO_START,
- :binary_path_name => cmd,
- :service_start_name => @service_start_name,
- :password => @password,
- )
+ :service_name => @service_name,
+ :display_name => @service_display_name,
+ :description => @service_description,
+ # Prior to 0.8.5, win32-service creates interactive services by default,
+ # and we don't want that, so we need to override the service type.
+ :service_type => ::Win32::Service::SERVICE_WIN32_OWN_PROCESS,
+ :start_type => ::Win32::Service::SERVICE_AUTO_START,
+ :binary_path_name => cmd,
+ :service_start_name => @service_start_name,
+ :password => @password,
+ )
+ ::Win32::Service.configure(
+ :service_name => @service_name,
+ :delayed_start => @delayed_start
+ )
puts "Service '#{@service_name}' has successfully been installed."
end
when 'status'