blob: 81a78cc5b3441d8299b424d500af9d9c4621cfe8 [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"
Ed Tanous3cd70722024-04-06 09:24:01 -070016#include "obmc_console.hpp"
17#include "openbmc_dbus_rest.hpp"
18#include "redfish.hpp"
19#include "redfish_aggregator.hpp"
Ed Tanous3cd70722024-04-06 09:24:01 -070020#include "user_monitor.hpp"
21#include "vm_websocket.hpp"
22#include "webassets.hpp"
23
Ed Tanous3cd70722024-04-06 09:24:01 -070024#include <boost/asio/io_context.hpp>
25#include <sdbusplus/asio/connection.hpp>
Ed Tanous5b904292024-04-16 11:10:17 -070026
27#include <memory>
Ed Tanous3cd70722024-04-06 09:24:01 -070028
Ed Tanous3cd70722024-04-06 09:24:01 -070029int run()
30{
31 auto io = std::make_shared<boost::asio::io_context>();
32 App app(io);
33
34 sdbusplus::asio::connection systemBus(*io);
35 crow::connections::systemBus = &systemBus;
36
37 // Static assets need to be initialized before Authorization, because auth
38 // needs to build the whitelist from the static routes
39
40#ifdef BMCWEB_ENABLE_STATIC_HOSTING
41 crow::webassets::requestRoutes(app);
42#endif
43
44#ifdef BMCWEB_ENABLE_KVM
45 crow::obmc_kvm::requestRoutes(app);
46#endif
47
48#ifdef BMCWEB_ENABLE_REDFISH
49 redfish::RedfishService redfish(app);
50
51 // Create EventServiceManager instance and initialize Config
52 redfish::EventServiceManager::getInstance(&*io);
53
54#ifdef BMCWEB_ENABLE_REDFISH_AGGREGATION
55 // Create RedfishAggregator instance and initialize Config
56 redfish::RedfishAggregator::getInstance(&*io);
57#endif
58#endif
59
60#ifdef BMCWEB_ENABLE_DBUS_REST
61 crow::dbus_monitor::requestRoutes(app);
62 crow::image_upload::requestRoutes(app);
63 crow::openbmc_mapper::requestRoutes(app);
64#endif
65
66#ifdef BMCWEB_ENABLE_HOST_SERIAL_WEBSOCKET
67 crow::obmc_console::requestRoutes(app);
68#endif
69
70#ifdef BMCWEB_ENABLE_VM_WEBSOCKET
71 crow::obmc_vm::requestRoutes(app);
72#endif
73
74#ifdef BMCWEB_ENABLE_IBM_MANAGEMENT_CONSOLE
75 crow::ibm_mc::requestRoutes(app);
Ed Tanous3cd70722024-04-06 09:24:01 -070076#endif
77
78#ifdef BMCWEB_ENABLE_GOOGLE_API
79 crow::google_api::requestRoutes(app);
80#endif
81
Ed Tanous3cd70722024-04-06 09:24:01 -070082 crow::login_routes::requestRoutes(app);
83
Ed Tanous3cd70722024-04-06 09:24:01 -070084#ifdef BMCWEB_ENABLE_VM_NBDPROXY
85 crow::nbd_proxy::requestRoutes(app);
86#endif
87
88#ifndef BMCWEB_ENABLE_REDFISH_DBUS_LOG_ENTRIES
89 int rc = redfish::EventServiceManager::startEventLogMonitor(*io);
90 if (rc != 0)
91 {
92 BMCWEB_LOG_ERROR("Redfish event handler setup failed...");
93 return rc;
94 }
95#endif
96
Ed Tanous8db83742024-04-13 09:11:15 -070097 if constexpr (bmcwebEnableTLS)
98 {
99 BMCWEB_LOG_INFO("Start Hostname Monitor Service...");
100 crow::hostname_monitor::registerHostnameSignal();
101 }
Ed Tanous3cd70722024-04-06 09:24:01 -0700102
103 bmcweb::registerUserRemovedSignal();
104
105 app.run();
106 io->run();
107
108 crow::connections::systemBus = nullptr;
109
110 return 0;
111}