Ed Tanous | 3cd7072 | 2024-04-06 09:24:01 -0700 | [diff] [blame] | 1 | #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" |
| 15 | #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" |
| 21 | #include "security_headers.hpp" |
| 22 | #include "ssl_key_handler.hpp" |
| 23 | #include "user_monitor.hpp" |
| 24 | #include "vm_websocket.hpp" |
| 25 | #include "webassets.hpp" |
| 26 | |
Ed Tanous | 3cd7072 | 2024-04-06 09:24:01 -0700 | [diff] [blame] | 27 | #include <boost/asio/io_context.hpp> |
| 28 | #include <sdbusplus/asio/connection.hpp> |
| 29 | #include <sdbusplus/bus.hpp> |
| 30 | #include <sdbusplus/server.hpp> |
| 31 | |
Ed Tanous | 3cd7072 | 2024-04-06 09:24:01 -0700 | [diff] [blame] | 32 | int run() |
| 33 | { |
| 34 | auto io = std::make_shared<boost::asio::io_context>(); |
| 35 | App app(io); |
| 36 | |
| 37 | sdbusplus::asio::connection systemBus(*io); |
| 38 | crow::connections::systemBus = &systemBus; |
| 39 | |
| 40 | // Static assets need to be initialized before Authorization, because auth |
| 41 | // needs to build the whitelist from the static routes |
| 42 | |
| 43 | #ifdef BMCWEB_ENABLE_STATIC_HOSTING |
| 44 | crow::webassets::requestRoutes(app); |
| 45 | #endif |
| 46 | |
| 47 | #ifdef BMCWEB_ENABLE_KVM |
| 48 | crow::obmc_kvm::requestRoutes(app); |
| 49 | #endif |
| 50 | |
| 51 | #ifdef BMCWEB_ENABLE_REDFISH |
| 52 | redfish::RedfishService redfish(app); |
| 53 | |
| 54 | // Create EventServiceManager instance and initialize Config |
| 55 | redfish::EventServiceManager::getInstance(&*io); |
| 56 | |
| 57 | #ifdef BMCWEB_ENABLE_REDFISH_AGGREGATION |
| 58 | // Create RedfishAggregator instance and initialize Config |
| 59 | redfish::RedfishAggregator::getInstance(&*io); |
| 60 | #endif |
| 61 | #endif |
| 62 | |
| 63 | #ifdef BMCWEB_ENABLE_DBUS_REST |
| 64 | crow::dbus_monitor::requestRoutes(app); |
| 65 | crow::image_upload::requestRoutes(app); |
| 66 | crow::openbmc_mapper::requestRoutes(app); |
| 67 | #endif |
| 68 | |
| 69 | #ifdef BMCWEB_ENABLE_HOST_SERIAL_WEBSOCKET |
| 70 | crow::obmc_console::requestRoutes(app); |
| 71 | #endif |
| 72 | |
| 73 | #ifdef BMCWEB_ENABLE_VM_WEBSOCKET |
| 74 | crow::obmc_vm::requestRoutes(app); |
| 75 | #endif |
| 76 | |
| 77 | #ifdef BMCWEB_ENABLE_IBM_MANAGEMENT_CONSOLE |
| 78 | crow::ibm_mc::requestRoutes(app); |
Ed Tanous | 3cd7072 | 2024-04-06 09:24:01 -0700 | [diff] [blame] | 79 | #endif |
| 80 | |
| 81 | #ifdef BMCWEB_ENABLE_GOOGLE_API |
| 82 | crow::google_api::requestRoutes(app); |
| 83 | #endif |
| 84 | |
| 85 | if (bmcwebInsecureDisableXssPrevention != 0) |
| 86 | { |
| 87 | cors_preflight::requestRoutes(app); |
| 88 | } |
| 89 | |
| 90 | crow::login_routes::requestRoutes(app); |
| 91 | |
Ed Tanous | 3cd7072 | 2024-04-06 09:24:01 -0700 | [diff] [blame] | 92 | #ifdef BMCWEB_ENABLE_VM_NBDPROXY |
| 93 | crow::nbd_proxy::requestRoutes(app); |
| 94 | #endif |
| 95 | |
| 96 | #ifndef BMCWEB_ENABLE_REDFISH_DBUS_LOG_ENTRIES |
| 97 | int rc = redfish::EventServiceManager::startEventLogMonitor(*io); |
| 98 | if (rc != 0) |
| 99 | { |
| 100 | BMCWEB_LOG_ERROR("Redfish event handler setup failed..."); |
| 101 | return rc; |
| 102 | } |
| 103 | #endif |
| 104 | |
Ed Tanous | 8db8374 | 2024-04-13 09:11:15 -0700 | [diff] [blame] | 105 | if constexpr (bmcwebEnableTLS) |
| 106 | { |
| 107 | BMCWEB_LOG_INFO("Start Hostname Monitor Service..."); |
| 108 | crow::hostname_monitor::registerHostnameSignal(); |
| 109 | } |
Ed Tanous | 3cd7072 | 2024-04-06 09:24:01 -0700 | [diff] [blame] | 110 | |
| 111 | bmcweb::registerUserRemovedSignal(); |
| 112 | |
| 113 | app.run(); |
| 114 | io->run(); |
| 115 | |
| 116 | crow::connections::systemBus = nullptr; |
| 117 | |
| 118 | return 0; |
| 119 | } |