Commit d95521e1 authored by Chris Roberts's avatar Chris Roberts Committed by Bryan McLellan
Browse files

Move chef client instantiation and run into isolated method

parent 2f6eae7d
......@@ -274,14 +274,7 @@ class Chef::Application::Client < Chef::Application
Chef::Log.debug("Splay sleep #{splay} seconds")
sleep splay
end
@chef_client = Chef::Client.new(
@chef_client_json,
:override_runlist => config[:override_runlist]
)
@chef_client_json = nil
@chef_client.run
@chef_client = nil
run_chef_client
if Chef::Config[:interval]
Chef::Log.debug("Sleeping for #{Chef::Config[:interval]} seconds")
unless SELF_PIPE.empty?
......@@ -320,6 +313,18 @@ class Chef::Application::Client < Chef::Application
private
# Initializes Chef::Client instance and runs it
def run_chef_client
@chef_client = Chef::Client.new(
@chef_client_json,
:override_runlist => config[:override_runlist]
)
@chef_client_json = nil
@chef_client.run
@chef_client = nil
end
def client_sleep(sec)
IO.select([ SELF_PIPE[0] ], nil, nil, sec) or return
SELF_PIPE[0].getc
......
......@@ -223,12 +223,7 @@ class Chef::Application::Solo < Chef::Application
sleep splay
end
@chef_solo = Chef::Client.new(
@chef_solo_json,
:override_runlist => config[:override_runlist]
)
@chef_solo.run
@chef_solo = nil
run_chef_client
if Chef::Config[:interval]
Chef::Log.debug("Sleeping for #{Chef::Config[:interval]} seconds")
sleep Chef::Config[:interval]
......@@ -251,4 +246,16 @@ class Chef::Application::Solo < Chef::Application
end
end
end
private
# Initializes Chef::Client instance and runs it
def run_chef_client
@chef_solo = Chef::Client.new(
@chef_solo_json,
:override_runlist => config[:override_runlist]
)
@chef_solo.run
@chef_solo = nil
end
end
......@@ -88,14 +88,7 @@ class Chef
# If we've stopped, then bail out now, instead of going on to run Chef
next if state != RUNNING
@chef_client = Chef::Client.new(
@chef_client_json,
:override_runlist => config[:override_runlist]
)
@chef_client_json = nil
@chef_client.run
@chef_client = nil
run_chef_client
Chef::Log.debug("Sleeping for #{Chef::Config[:interval]} seconds")
client_sleep Chef::Config[:interval]
......@@ -225,6 +218,20 @@ class Chef
sleep chunk_length
end
end
private
# Initializes Chef::Client instance and runs it
def run_chef_client
@chef_client = Chef::Client.new(
@chef_client_json,
:override_runlist => config[:override_runlist]
)
@chef_client_json = nil
@chef_client.run
@chef_client = nil
end
end
end
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment