blob: f02ead96b9849e524eb0ec1b7b6187e5fc2e513c [file] [log] [blame]
Ed Tanous3cd70722024-04-06 09:24:01 -07001#include "webserver_run.hpp"
2
3#include "bmcweb_config.h"
4
5#include "app.hpp"
Ed Tanous3cd70722024-04-06 09:24:01 -07006#include "dbus_monitor.hpp"
7#include "dbus_singleton.hpp"
8#include "event_service_manager.hpp"
9#include "google/google_service_root.hpp"
10#include "hostname_monitor.hpp"
11#include "ibm/management_console_rest.hpp"
12#include "image_upload.hpp"
13#include "kvm_websocket.hpp"
Ed Tanous5b904292024-04-16 11:10:17 -070014#include "logging.hpp"
Ed Tanous3cd70722024-04-06 09:24:01 -070015#include "login_routes.hpp"
16#include "nbd_proxy.hpp"
17#include "obmc_console.hpp"
18#include "openbmc_dbus_rest.hpp"
19#include "redfish.hpp"
20#include "redfish_aggregator.hpp"
Ed Tanous3cd70722024-04-06 09:24:01 -070021#include "user_monitor.hpp"
22#include "vm_websocket.hpp"
23#include "webassets.hpp"
24
Ed Tanous3cd70722024-04-06 09:24:01 -070025#include <boost/asio/io_context.hpp>
26#include <sdbusplus/asio/connection.hpp>
Ed Tanous5b904292024-04-16 11:10:17 -070027
28#include <memory>
Ed Tanous3cd70722024-04-06 09:24:01 -070029
Ed Tanous3cd70722024-04-06 09:24:01 -070030int run()
31{
32 auto io = std::make_shared<boost::asio::io_context>();
33 App app(io);
34
35 sdbusplus::asio::connection systemBus(*io);
36 crow::connections::systemBus = &systemBus;
37
38 // Static assets need to be initialized before Authorization, because auth
39 // needs to build the whitelist from the static routes
40
41#ifdef BMCWEB_ENABLE_STATIC_HOSTING
42 crow::webassets::requestRoutes(app);
43#endif
44
45#ifdef BMCWEB_ENABLE_KVM
46 crow::obmc_kvm::requestRoutes(app);
47#endif
48
49#ifdef BMCWEB_ENABLE_REDFISH
50 redfish::RedfishService redfish(app);
51
52 // Create EventServiceManager instance and initialize Config
53 redfish::EventServiceManager::getInstance(&*io);
54
55#ifdef BMCWEB_ENABLE_REDFISH_AGGREGATION
56 // Create RedfishAggregator instance and initialize Config
57 redfish::RedfishAggregator::getInstance(&*io);
58#endif
59#endif
60
61#ifdef BMCWEB_ENABLE_DBUS_REST
62 crow::dbus_monitor::requestRoutes(app);
63 crow::image_upload::requestRoutes(app);
64 crow::openbmc_mapper::requestRoutes(app);
65#endif
66
67#ifdef BMCWEB_ENABLE_HOST_SERIAL_WEBSOCKET
68 crow::obmc_console::requestRoutes(app);
69#endif
70
71#ifdef BMCWEB_ENABLE_VM_WEBSOCKET
72 crow::obmc_vm::requestRoutes(app);
73#endif
74
75#ifdef BMCWEB_ENABLE_IBM_MANAGEMENT_CONSOLE
76 crow::ibm_mc::requestRoutes(app);
Ed Tanous3cd70722024-04-06 09:24:01 -070077#endif
78
79#ifdef BMCWEB_ENABLE_GOOGLE_API
80 crow::google_api::requestRoutes(app);
81#endif
82
Ed Tanous3cd70722024-04-06 09:24:01 -070083 crow::login_routes::requestRoutes(app);
84
Ed Tanous3cd70722024-04-06 09:24:01 -070085#ifdef BMCWEB_ENABLE_VM_NBDPROXY
86 crow::nbd_proxy::requestRoutes(app);
87#endif
88
89#ifndef BMCWEB_ENABLE_REDFISH_DBUS_LOG_ENTRIES
90 int rc = redfish::EventServiceManager::startEventLogMonitor(*io);
91 if (rc != 0)
92 {
93 BMCWEB_LOG_ERROR("Redfish event handler setup failed...");
94 return rc;
95 }
96#endif
97
Ed Tanous8db83742024-04-13 09:11:15 -070098 if constexpr (bmcwebEnableTLS)
99 {
100 BMCWEB_LOG_INFO("Start Hostname Monitor Service...");
101 crow::hostname_monitor::registerHostnameSignal();
102 }
Ed Tanous3cd70722024-04-06 09:24:01 -0700103
104 bmcweb::registerUserRemovedSignal();
105
106 app.run();
107 io->run();
108
109 crow::connections::systemBus = nullptr;
110
111 return 0;
112}