xref: /openbmc/phosphor-pid-control/main.cpp (revision bd63bcaca2ac9edf1778136cf240e3bbe8b31566)
1e620656cSPatrick Venture /**
2e620656cSPatrick Venture  * Copyright 2017 Google Inc.
3e620656cSPatrick Venture  *
4e620656cSPatrick Venture  * Licensed under the Apache License, Version 2.0 (the "License");
5e620656cSPatrick Venture  * you may not use this file except in compliance with the License.
6e620656cSPatrick Venture  * You may obtain a copy of the License at
7e620656cSPatrick Venture  *
8e620656cSPatrick Venture  *     http://www.apache.org/licenses/LICENSE-2.0
9e620656cSPatrick Venture  *
10e620656cSPatrick Venture  * Unless required by applicable law or agreed to in writing, software
11e620656cSPatrick Venture  * distributed under the License is distributed on an "AS IS" BASIS,
12e620656cSPatrick Venture  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13e620656cSPatrick Venture  * See the License for the specific language governing permissions and
14e620656cSPatrick Venture  * limitations under the License.
15e620656cSPatrick Venture  */
16e620656cSPatrick Venture 
177136a5aeSJames Feist #include "config.h"
18e620656cSPatrick Venture 
193dcfd546SHarvey Wu #include "buildjson/buildjson.hpp"
20da4a5dd1SPatrick Venture #include "conf.hpp"
217f9d690dSPatrick Venture #include "dbus/dbusconfiguration.hpp"
22e620656cSPatrick Venture #include "interfaces.hpp"
235c7cc545SPatrick Venture #include "pid/builder.hpp"
24ba8ffa73SPatrick Venture #include "pid/buildjson.hpp"
25ce6a3f36SJames Feist #include "pid/pidloop.hpp"
26c32e3fc5SPatrick Venture #include "pid/tuning.hpp"
27e620656cSPatrick Venture #include "pid/zone.hpp"
285e929093SPatrick Venture #include "sensors/builder.hpp"
29ba8ffa73SPatrick Venture #include "sensors/buildjson.hpp"
30e620656cSPatrick Venture #include "sensors/manager.hpp"
31da4a5dd1SPatrick Venture #include "util.hpp"
32e620656cSPatrick Venture 
33b5cc37ceSPatrick Venture #include <CLI/CLI.hpp>
34ce6a3f36SJames Feist #include <boost/asio/io_context.hpp>
35e2ec69adSPotin Lai #include <boost/asio/signal_set.hpp>
36ce6a3f36SJames Feist #include <boost/asio/steady_timer.hpp>
37a83a3eccSPatrick Venture #include <sdbusplus/asio/connection.hpp>
38a83a3eccSPatrick Venture #include <sdbusplus/bus.hpp>
39cb4c1a27SBruce Lee #include <sdbusplus/server/manager.hpp>
40a83a3eccSPatrick Venture 
41da4a5dd1SPatrick Venture #include <chrono>
427f9d690dSPatrick Venture #include <filesystem>
43da4a5dd1SPatrick Venture #include <iostream>
44ce6a3f36SJames Feist #include <list>
45da4a5dd1SPatrick Venture #include <map>
46da4a5dd1SPatrick Venture #include <memory>
47da4a5dd1SPatrick Venture #include <thread>
48da4a5dd1SPatrick Venture #include <unordered_map>
49ba8ffa73SPatrick Venture #include <utility>
50da4a5dd1SPatrick Venture #include <vector>
51e620656cSPatrick Venture 
52a076487aSPatrick Venture namespace pid_control
53a076487aSPatrick Venture {
54a076487aSPatrick Venture 
551fe08952SJames Feist /* The configuration converted sensor list. */
561df9e879SPatrick Venture std::map<std::string, conf::SensorConfig> sensorConfig = {};
571fe08952SJames Feist /* The configuration converted PID list. */
58f81f2886SJames Feist std::map<int64_t, conf::PIDConf> zoneConfig = {};
591fe08952SJames Feist /* The configuration converted Zone configuration. */
601df9e879SPatrick Venture std::map<int64_t, conf::ZoneConfig> zoneDetailsConfig = {};
61e620656cSPatrick Venture 
62c7b2be39SPatrick Rudolph namespace state
63c7b2be39SPatrick Rudolph {
64c7b2be39SPatrick Rudolph /* Set to true while canceling is in progress */
65c7b2be39SPatrick Rudolph static bool isCanceling = false;
66c7b2be39SPatrick Rudolph /* The zones build from configuration */
67c7b2be39SPatrick Rudolph static std::unordered_map<int64_t, std::shared_ptr<ZoneInterface>> zones;
68c7b2be39SPatrick Rudolph /* The timers used by the PID loop */
69c7b2be39SPatrick Rudolph static std::vector<std::shared_ptr<boost::asio::steady_timer>> timers;
70c7b2be39SPatrick Rudolph /* The sensors build from configuration */
71c7b2be39SPatrick Rudolph static SensorManager mgmr;
72c7b2be39SPatrick Rudolph } // namespace state
73c7b2be39SPatrick Rudolph 
74a076487aSPatrick Venture } // namespace pid_control
75a076487aSPatrick Venture 
7679cde00aSPotin Lai std::filesystem::path configPath = "";
77e620656cSPatrick Venture 
781fe08952SJames Feist /* async io context for operation */
791fe08952SJames Feist boost::asio::io_context io;
80e2ec69adSPotin Lai /* async signal_set for signal handling */
81c7b2be39SPatrick Rudolph boost::asio::signal_set signals(io, SIGHUP, SIGTERM);
82e620656cSPatrick Venture 
831fe08952SJames Feist /* buses for system control */
841fe08952SJames Feist static sdbusplus::asio::connection modeControlBus(io);
851fe08952SJames Feist static sdbusplus::asio::connection
861fe08952SJames Feist     hostBus(io, sdbusplus::bus::new_system().release());
871fe08952SJames Feist static sdbusplus::asio::connection
881fe08952SJames Feist     passiveBus(io, sdbusplus::bus::new_system().release());
89de79ee05SPatrick Venture 
90a076487aSPatrick Venture namespace pid_control
91a076487aSPatrick Venture {
92a076487aSPatrick Venture 
searchConfigurationPath()9379cde00aSPotin Lai std::filesystem::path searchConfigurationPath()
9479cde00aSPotin Lai {
9579cde00aSPotin Lai     static constexpr auto name = "config.json";
9679cde00aSPotin Lai 
9779cde00aSPotin Lai     for (auto pathSeg : {std::filesystem::current_path(),
9879cde00aSPotin Lai                          std::filesystem::path{"/var/lib/swampd"},
9979cde00aSPotin Lai                          std::filesystem::path{"/usr/share/swampd"}})
10079cde00aSPotin Lai     {
10179cde00aSPotin Lai         auto file = pathSeg / name;
10279cde00aSPotin Lai         if (std::filesystem::exists(file))
10379cde00aSPotin Lai         {
10479cde00aSPotin Lai             return file;
10579cde00aSPotin Lai         }
10679cde00aSPotin Lai     }
10779cde00aSPotin Lai 
10879cde00aSPotin Lai     return name;
10979cde00aSPotin Lai }
11079cde00aSPotin Lai 
stopControlLoops()111c7b2be39SPatrick Rudolph void stopControlLoops()
1121fe08952SJames Feist {
113c7b2be39SPatrick Rudolph     for (const auto& timer : state::timers)
1145301aae3SJohnathan Mantey     {
1155301aae3SJohnathan Mantey         timer->cancel();
1165301aae3SJohnathan Mantey     }
117c7b2be39SPatrick Rudolph     state::isCanceling = true;
118c7b2be39SPatrick Rudolph     state::timers.clear();
119b228cea2SHao Jiang 
120c7b2be39SPatrick Rudolph     if (state::zones.size() > 0 && state::zones.begin()->second.use_count() > 1)
121b228cea2SHao Jiang     {
122b228cea2SHao Jiang         throw std::runtime_error("wait for count back to 1");
123b228cea2SHao Jiang     }
124c7b2be39SPatrick Rudolph 
125c7b2be39SPatrick Rudolph     state::zones.clear();
126c7b2be39SPatrick Rudolph     state::isCanceling = false;
127c7b2be39SPatrick Rudolph }
128c7b2be39SPatrick Rudolph 
restartControlLoops()129c7b2be39SPatrick Rudolph void restartControlLoops()
130c7b2be39SPatrick Rudolph {
131c7b2be39SPatrick Rudolph     stopControlLoops();
1324cb7c058SPatrick Venture 
13379cde00aSPotin Lai     const std::filesystem::path path =
13479cde00aSPotin Lai         (!configPath.empty()) ? configPath : searchConfigurationPath();
135e620656cSPatrick Venture 
1367f9d690dSPatrick Venture     if (std::filesystem::exists(path))
1377f9d690dSPatrick Venture     {
138e620656cSPatrick Venture         /*
1397f9d690dSPatrick Venture          * When building the sensors, if any of the dbus passive ones aren't on
1407f9d690dSPatrick Venture          * the bus, it'll fail immediately.
141e620656cSPatrick Venture          */
142e620656cSPatrick Venture         try
143e620656cSPatrick Venture         {
14418b1311eSPatrick Venture             auto jsonData = parseValidateJson(path);
1454cb7c058SPatrick Venture             sensorConfig = buildSensorsFromJson(jsonData);
146*bd63bcacSPatrick Williams             std::tie(zoneConfig, zoneDetailsConfig) =
147*bd63bcacSPatrick Williams                 buildPIDsFromJson(jsonData);
148e620656cSPatrick Venture         }
149e620656cSPatrick Venture         catch (const std::exception& e)
150e620656cSPatrick Venture         {
151e620656cSPatrick Venture             std::cerr << "Failed during building: " << e.what() << "\n";
152e620656cSPatrick Venture             exit(EXIT_FAILURE); /* fatal error. */
153e620656cSPatrick Venture         }
1547f9d690dSPatrick Venture     }
1557f9d690dSPatrick Venture     else
1567f9d690dSPatrick Venture     {
1577f9d690dSPatrick Venture         static boost::asio::steady_timer reloadTimer(io);
1587382318fSPatrick Venture         if (!dbus_configuration::init(modeControlBus, reloadTimer, sensorConfig,
1597382318fSPatrick Venture                                       zoneConfig, zoneDetailsConfig))
1607f9d690dSPatrick Venture         {
1617f9d690dSPatrick Venture             return; // configuration not ready
1627f9d690dSPatrick Venture         }
1637f9d690dSPatrick Venture     }
1644cb7c058SPatrick Venture 
165c7b2be39SPatrick Rudolph     state::mgmr = buildSensors(sensorConfig, passiveBus, hostBus);
166*bd63bcacSPatrick Williams     state::zones =
167*bd63bcacSPatrick Williams         buildZones(zoneConfig, zoneDetailsConfig, state::mgmr, modeControlBus);
168e620656cSPatrick Venture 
169c7b2be39SPatrick Rudolph     if (0 == state::zones.size())
170e620656cSPatrick Venture     {
171e620656cSPatrick Venture         std::cerr << "No zones defined, exiting.\n";
1721fe08952SJames Feist         std::exit(EXIT_FAILURE);
173e620656cSPatrick Venture     }
174e620656cSPatrick Venture 
175c7b2be39SPatrick Rudolph     for (const auto& i : state::zones)
1761fe08952SJames Feist     {
177c7b2be39SPatrick Rudolph         std::shared_ptr<boost::asio::steady_timer> timer =
178c7b2be39SPatrick Rudolph             state::timers.emplace_back(
1795301aae3SJohnathan Mantey                 std::make_shared<boost::asio::steady_timer>(io));
1801fe08952SJames Feist         std::cerr << "pushing zone " << i.first << "\n";
181c7b2be39SPatrick Rudolph         pidControlLoop(i.second, timer, &state::isCanceling);
1821fe08952SJames Feist     }
1831fe08952SJames Feist }
1841fe08952SJames Feist 
tryRestartControlLoops(bool first)185b228cea2SHao Jiang void tryRestartControlLoops(bool first)
186298a95cbSYong Li {
187d11a732aSHao Jiang     static const auto delayTime = std::chrono::seconds(10);
188b228cea2SHao Jiang     static boost::asio::steady_timer timer(io);
189d11a732aSHao Jiang 
190d11a732aSHao Jiang     auto restartLbd = [](const boost::system::error_code& error) {
191b228cea2SHao Jiang         if (error == boost::asio::error::operation_aborted)
192b228cea2SHao Jiang         {
193b228cea2SHao Jiang             return;
194b228cea2SHao Jiang         }
195232ffe4eSHao Jiang 
196232ffe4eSHao Jiang         // retry when restartControlLoops() has some failure.
197298a95cbSYong Li         try
198298a95cbSYong Li         {
199298a95cbSYong Li             restartControlLoops();
200298a95cbSYong Li         }
201298a95cbSYong Li         catch (const std::exception& e)
202298a95cbSYong Li         {
2035293ec2eSZev Weiss             std::cerr << "Failed during restartControlLoops, try again: "
204298a95cbSYong Li                       << e.what() << "\n";
205b228cea2SHao Jiang             tryRestartControlLoops(false);
206298a95cbSYong Li         }
207d11a732aSHao Jiang     };
2085293ec2eSZev Weiss 
209d11a732aSHao Jiang     // first time of trying to restart the control loop without a delay
210d11a732aSHao Jiang     if (first)
211d11a732aSHao Jiang     {
212d11a732aSHao Jiang         boost::asio::post(io,
213d11a732aSHao Jiang                           std::bind(restartLbd, boost::system::error_code()));
214d11a732aSHao Jiang     }
215d11a732aSHao Jiang     // re-try control loop, set up a delay.
216d11a732aSHao Jiang     else
217d11a732aSHao Jiang     {
218d11a732aSHao Jiang         timer.expires_after(delayTime);
219d11a732aSHao Jiang         timer.async_wait(restartLbd);
220d11a732aSHao Jiang     }
221298a95cbSYong Li 
222298a95cbSYong Li     return;
223298a95cbSYong Li }
224298a95cbSYong Li 
tryTerminateControlLoops(bool first)225c7b2be39SPatrick Rudolph void tryTerminateControlLoops(bool first)
226c7b2be39SPatrick Rudolph {
227c7b2be39SPatrick Rudolph     static const auto delayTime = std::chrono::milliseconds(50);
228c7b2be39SPatrick Rudolph     static boost::asio::steady_timer timer(io);
229c7b2be39SPatrick Rudolph 
230c7b2be39SPatrick Rudolph     auto stopLbd = [](const boost::system::error_code& error) {
231c7b2be39SPatrick Rudolph         if (error == boost::asio::error::operation_aborted)
232c7b2be39SPatrick Rudolph         {
233c7b2be39SPatrick Rudolph             return;
234c7b2be39SPatrick Rudolph         }
235c7b2be39SPatrick Rudolph 
236c7b2be39SPatrick Rudolph         // retry when stopControlLoops() has some failure.
237c7b2be39SPatrick Rudolph         try
238c7b2be39SPatrick Rudolph         {
239c7b2be39SPatrick Rudolph             stopControlLoops();
240c7b2be39SPatrick Rudolph         }
241c7b2be39SPatrick Rudolph         catch (const std::exception& e)
242c7b2be39SPatrick Rudolph         {
243c7b2be39SPatrick Rudolph             std::cerr << "Failed during stopControlLoops, try again: "
244c7b2be39SPatrick Rudolph                       << e.what() << "\n";
245c7b2be39SPatrick Rudolph             tryTerminateControlLoops(false);
246c7b2be39SPatrick Rudolph             return;
247c7b2be39SPatrick Rudolph         }
248c7b2be39SPatrick Rudolph         io.stop();
249c7b2be39SPatrick Rudolph     };
250c7b2be39SPatrick Rudolph 
251c7b2be39SPatrick Rudolph     // first time of trying to stop the control loop without a delay
252c7b2be39SPatrick Rudolph     if (first)
253c7b2be39SPatrick Rudolph     {
254c7b2be39SPatrick Rudolph         boost::asio::post(io, std::bind(stopLbd, boost::system::error_code()));
255c7b2be39SPatrick Rudolph     }
256c7b2be39SPatrick Rudolph     // re-try control loop, set up a delay.
257c7b2be39SPatrick Rudolph     else
258c7b2be39SPatrick Rudolph     {
259c7b2be39SPatrick Rudolph         timer.expires_after(delayTime);
260c7b2be39SPatrick Rudolph         timer.async_wait(stopLbd);
261c7b2be39SPatrick Rudolph     }
262c7b2be39SPatrick Rudolph 
263c7b2be39SPatrick Rudolph     return;
264c7b2be39SPatrick Rudolph }
265c7b2be39SPatrick Rudolph 
266a076487aSPatrick Venture } // namespace pid_control
267a076487aSPatrick Venture 
signalHandler(const boost::system::error_code & error,int signal_number)268c7b2be39SPatrick Rudolph void signalHandler(const boost::system::error_code& error, int signal_number)
269e2ec69adSPotin Lai {
270e2ec69adSPotin Lai     static boost::asio::steady_timer timer(io);
271e2ec69adSPotin Lai 
272e2ec69adSPotin Lai     if (error)
273e2ec69adSPotin Lai     {
274e2ec69adSPotin Lai         std::cout << "Signal " << signal_number
275e2ec69adSPotin Lai                   << " handler error: " << error.message() << "\n";
276e2ec69adSPotin Lai         return;
277e2ec69adSPotin Lai     }
278c7b2be39SPatrick Rudolph     if (signal_number == SIGTERM)
279c7b2be39SPatrick Rudolph     {
280c7b2be39SPatrick Rudolph         pid_control::tryTerminateControlLoops(true);
281c7b2be39SPatrick Rudolph     }
282c7b2be39SPatrick Rudolph     else
283c7b2be39SPatrick Rudolph     {
284e2ec69adSPotin Lai         timer.expires_after(std::chrono::seconds(1));
285e2ec69adSPotin Lai         timer.async_wait([](const boost::system::error_code ec) {
286e2ec69adSPotin Lai             if (ec)
287e2ec69adSPotin Lai             {
288e2ec69adSPotin Lai                 std::cout << "Signal timer error: " << ec.message() << "\n";
289e2ec69adSPotin Lai                 return;
290e2ec69adSPotin Lai             }
291e2ec69adSPotin Lai 
292e2ec69adSPotin Lai             std::cout << "reloading configuration\n";
293e2ec69adSPotin Lai             pid_control::tryRestartControlLoops();
294e2ec69adSPotin Lai         });
295c7b2be39SPatrick Rudolph     }
296c7b2be39SPatrick Rudolph 
297c7b2be39SPatrick Rudolph     signals.async_wait(signalHandler);
298e2ec69adSPotin Lai }
299e2ec69adSPotin Lai 
main(int argc,char * argv[])3001fe08952SJames Feist int main(int argc, char* argv[])
3011fe08952SJames Feist {
3021fe08952SJames Feist     loggingPath = "";
3031fe08952SJames Feist     loggingEnabled = false;
3041fe08952SJames Feist     tuningEnabled = false;
305c51ba919SBonnie Lo     debugEnabled = false;
306de74542cSJosh Lehan     coreLoggingEnabled = false;
3071fe08952SJames Feist 
3081fe08952SJames Feist     CLI::App app{"OpenBMC Fan Control Daemon"};
3091fe08952SJames Feist 
3101fe08952SJames Feist     app.add_option("-c,--conf", configPath,
3111fe08952SJames Feist                    "Optional parameter to specify configuration at run-time")
3121fe08952SJames Feist         ->check(CLI::ExistingFile);
3131fe08952SJames Feist     app.add_option("-l,--log", loggingPath,
3141fe08952SJames Feist                    "Optional parameter to specify logging folder")
3151fe08952SJames Feist         ->check(CLI::ExistingDirectory);
3161fe08952SJames Feist     app.add_flag("-t,--tuning", tuningEnabled, "Enable or disable tuning");
317c51ba919SBonnie Lo     app.add_flag("-d,--debug", debugEnabled, "Enable or disable debug mode");
318de74542cSJosh Lehan     app.add_flag("-g,--corelogging", coreLoggingEnabled,
319de74542cSJosh Lehan                  "Enable or disable logging of core PID loop computations");
3201fe08952SJames Feist 
3211fe08952SJames Feist     CLI11_PARSE(app, argc, argv);
3221fe08952SJames Feist 
323811f31d6SJosh Lehan     static constexpr auto loggingEnablePath = "/etc/thermal.d/logging";
324811f31d6SJosh Lehan     static constexpr auto tuningEnablePath = "/etc/thermal.d/tuning";
325c51ba919SBonnie Lo     static constexpr auto debugEnablePath = "/etc/thermal.d/debugging";
326de74542cSJosh Lehan     static constexpr auto coreLoggingEnablePath = "/etc/thermal.d/corelogging";
327811f31d6SJosh Lehan 
328f54b260bSJosh Lehan     // Set up default logging path, preferring command line if it was given
329f54b260bSJosh Lehan     std::string defLoggingPath(loggingPath);
330f54b260bSJosh Lehan     if (defLoggingPath.empty())
331f54b260bSJosh Lehan     {
332f54b260bSJosh Lehan         defLoggingPath = std::filesystem::temp_directory_path();
333f54b260bSJosh Lehan     }
334f54b260bSJosh Lehan     else
335f54b260bSJosh Lehan     {
336f54b260bSJosh Lehan         // Enable logging, if user explicitly gave path on command line
337f54b260bSJosh Lehan         loggingEnabled = true;
338f54b260bSJosh Lehan     }
339f54b260bSJosh Lehan 
340811f31d6SJosh Lehan     // If this file exists, enable logging at runtime
341811f31d6SJosh Lehan     std::ifstream fsLogging(loggingEnablePath);
342811f31d6SJosh Lehan     if (fsLogging)
343811f31d6SJosh Lehan     {
344de74542cSJosh Lehan         // Allow logging path to be changed by file content
345de74542cSJosh Lehan         std::string altPath;
346de74542cSJosh Lehan         std::getline(fsLogging, altPath);
347811f31d6SJosh Lehan         fsLogging.close();
348811f31d6SJosh Lehan 
349de74542cSJosh Lehan         if (std::filesystem::exists(altPath))
350f54b260bSJosh Lehan         {
351de74542cSJosh Lehan             loggingPath = altPath;
352f54b260bSJosh Lehan         }
353cdc8dca4SJinliang Wang         else
354cdc8dca4SJinliang Wang         {
355cdc8dca4SJinliang Wang             loggingPath = defLoggingPath;
356cdc8dca4SJinliang Wang         }
357f54b260bSJosh Lehan 
358811f31d6SJosh Lehan         loggingEnabled = true;
359f54b260bSJosh Lehan     }
360f54b260bSJosh Lehan     if (loggingEnabled)
361f54b260bSJosh Lehan     {
362811f31d6SJosh Lehan         std::cerr << "Logging enabled: " << loggingPath << "\n";
363811f31d6SJosh Lehan     }
364811f31d6SJosh Lehan 
365811f31d6SJosh Lehan     // If this file exists, enable tuning at runtime
366811f31d6SJosh Lehan     if (std::filesystem::exists(tuningEnablePath))
367811f31d6SJosh Lehan     {
368811f31d6SJosh Lehan         tuningEnabled = true;
369f54b260bSJosh Lehan     }
370f54b260bSJosh Lehan     if (tuningEnabled)
371f54b260bSJosh Lehan     {
372811f31d6SJosh Lehan         std::cerr << "Tuning enabled\n";
373811f31d6SJosh Lehan     }
374d4695590SKun Yi 
375c51ba919SBonnie Lo     // If this file exists, enable debug mode at runtime
376c51ba919SBonnie Lo     if (std::filesystem::exists(debugEnablePath))
377c51ba919SBonnie Lo     {
378c51ba919SBonnie Lo         debugEnabled = true;
379c51ba919SBonnie Lo     }
380c51ba919SBonnie Lo 
381c51ba919SBonnie Lo     if (debugEnabled)
382c51ba919SBonnie Lo     {
383c51ba919SBonnie Lo         std::cerr << "Debug mode enabled\n";
384c51ba919SBonnie Lo     }
385c51ba919SBonnie Lo 
386de74542cSJosh Lehan     // If this file exists, enable core logging at runtime
387de74542cSJosh Lehan     if (std::filesystem::exists(coreLoggingEnablePath))
388de74542cSJosh Lehan     {
389de74542cSJosh Lehan         coreLoggingEnabled = true;
390de74542cSJosh Lehan     }
391de74542cSJosh Lehan     if (coreLoggingEnabled)
392de74542cSJosh Lehan     {
393de74542cSJosh Lehan         std::cerr << "Core logging enabled\n";
394de74542cSJosh Lehan     }
395de74542cSJosh Lehan 
3961fe08952SJames Feist     static constexpr auto modeRoot = "/xyz/openbmc_project/settings/fanctrl";
3971fe08952SJames Feist     // Create a manager for the ModeBus because we own it.
398b228bc30SPatrick Williams     sdbusplus::server::manager_t(static_cast<sdbusplus::bus_t&>(modeControlBus),
399b228bc30SPatrick Williams                                  modeRoot);
4001fe08952SJames Feist     hostBus.request_name("xyz.openbmc_project.Hwmon.external");
4011fe08952SJames Feist     modeControlBus.request_name("xyz.openbmc_project.State.FanCtrl");
402b228bc30SPatrick Williams     sdbusplus::server::manager_t objManager(modeControlBus, modeRoot);
4031fe08952SJames Feist 
404e2ec69adSPotin Lai     // Enable SIGHUP handling to reload JSON config
405c7b2be39SPatrick Rudolph     signals.async_wait(signalHandler);
406e2ec69adSPotin Lai 
407e620656cSPatrick Venture     /*
408e620656cSPatrick Venture      * All sensors are managed by one manager, but each zone has a pointer to
409e620656cSPatrick Venture      * it.
410e620656cSPatrick Venture      */
411e620656cSPatrick Venture 
412a076487aSPatrick Venture     pid_control::tryRestartControlLoops();
413e620656cSPatrick Venture 
414ce6a3f36SJames Feist     io.run();
4151fe08952SJames Feist     return 0;
416e620656cSPatrick Venture }
417