@@ -272,6 +272,7 @@ class Service
272272 # * failure_command => nil,
273273 # * failure_actions => nil,
274274 # * failure_delay => 0
275+ # * failure_flag => nil
275276 #
276277 # Example:
277278 #
@@ -317,6 +318,7 @@ def initialize(options = {})
317318 "failure_command" => nil ,
318319 "failure_actions" => nil ,
319320 "failure_delay" => 0 ,
321+ "failure_flag" => nil ,
320322 "host" => nil ,
321323 "service_name" => nil ,
322324 }
@@ -396,7 +398,7 @@ def initialize(options = {})
396398 end
397399
398400 if opts [ "failure_reset_period" ] || opts [ "failure_reboot_message" ] ||
399- opts [ "failure_command" ] || opts [ "failure_actions" ]
401+ opts [ "failure_command" ] || opts [ "failure_actions" ] || ! opts [ "failure_flag" ] . nil?
400402 self . class . configure_failure_actions ( handle_scs , opts )
401403 end
402404 ensure
@@ -425,6 +427,7 @@ def initialize(options = {})
425427 # * failure_reboot_message
426428 # * failure_command
427429 # * failure_actions
430+ # * failure_flag
428431 # * failure_delay
429432 #
430433 # Examples:
@@ -475,6 +478,7 @@ def self.configure(options = {})
475478 "failure_command" => nil ,
476479 "failure_actions" => nil ,
477480 "failure_delay" => 0 ,
481+ "failure_flag" => nil ,
478482 "service_name" => nil ,
479483 "host" => nil ,
480484 "delayed_start" => false ,
@@ -579,7 +583,7 @@ def self.configure(options = {})
579583 end
580584
581585 if opts [ "failure_reset_period" ] || opts [ "failure_reboot_message" ] ||
582- opts [ "failure_command" ] || opts [ "failure_actions" ]
586+ opts [ "failure_command" ] || opts [ "failure_actions" ] || ! opts [ "failure_flag" ] . nil?
583587 configure_failure_actions ( handle_scs , opts )
584588 end
585589 ensure
@@ -1397,6 +1401,18 @@ def self.configure_failure_actions(handle_scs, opts)
13971401 close_service_handle ( handle_scs )
13981402 raise SystemCallError . new ( "ChangeServiceConfig2" , error )
13991403 end
1404+
1405+ unless opts [ "failure_flag" ] . nil?
1406+ sfaf = SERVICE_FAILURE_ACTIONS_FLAG . new
1407+ sfaf [ :fFailureActionsOnNonCrashFailures ] = opts [ "failure_flag" ] ? 1 : 0
1408+ bool = ChangeServiceConfig2 (
1409+ handle_scs ,
1410+ SERVICE_CONFIG_FAILURE_ACTIONS_FLAG ,
1411+ sfaf
1412+ )
1413+
1414+ FFI . raise_windows_error ( "ChangeServiceConfig2" ) unless bool
1415+ end
14001416 end
14011417
14021418 # Returns a human readable string indicating the action type.
0 commit comments