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