Skip to content

Commit 36cee5e

Browse files
ctennisbtm
authored andcommitted
Add ability for SIGUSR1 to wakeup the daemon and start a chef run.
1 parent 6839075 commit 36cee5e

2 files changed

Lines changed: 17 additions & 0 deletions

File tree

chef/lib/chef/application.rb

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,9 @@
2424
class Chef::Application
2525
include Mixlib::CLI
2626

27+
class Wakeup < Exception
28+
end
29+
2730
def initialize
2831
super
2932

@@ -46,6 +49,17 @@ def initialize
4649
end
4750
end
4851

52+
unless RUBY_PLATFORM =~ /mswin|mingw32|windows/
53+
trap("USR1") do
54+
Chef::Log.info("SIGUSR1 received, starting run")
55+
raise Chef::Application::Wakeup
56+
end
57+
end
58+
59+
at_exit do
60+
# tear down the logger
61+
end
62+
4963
# Always switch to a readable directory. Keeps subsequent Dir.chdir() {}
5064
# from failing due to permissions when launched as a less privileged user.
5165
end

chef/lib/chef/application/client.rb

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -223,6 +223,9 @@ def run_application
223223
else
224224
Chef::Application.exit! "Exiting", 0
225225
end
226+
rescue Chef::Application::Wakeup => e
227+
Chef::Log.debug("Received Wakeup signal. Starting run.")
228+
next
226229
rescue SystemExit => e
227230
raise
228231
rescue Exception => e

0 commit comments

Comments
 (0)