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); |
| 79 | crow::ibm_mc_lock::Lock::getInstance(); |
| 80 | #endif |
| 81 | |
| 82 | #ifdef BMCWEB_ENABLE_GOOGLE_API |
| 83 | crow::google_api::requestRoutes(app); |
| 84 | #endif |
| 85 | |
| 86 | if (bmcwebInsecureDisableXssPrevention != 0) |
| 87 | { |
| 88 | cors_preflight::requestRoutes(app); |
| 89 | } |
| 90 | |
| 91 | crow::login_routes::requestRoutes(app); |
| 92 | |
Ed Tanous | 3cd7072 | 2024-04-06 09:24:01 -0700 | [diff] [blame] | 93 | #ifdef BMCWEB_ENABLE_VM_NBDPROXY |
| 94 | crow::nbd_proxy::requestRoutes(app); |
| 95 | #endif |
| 96 | |
| 97 | #ifndef BMCWEB_ENABLE_REDFISH_DBUS_LOG_ENTRIES |
| 98 | int rc = redfish::EventServiceManager::startEventLogMonitor(*io); |
| 99 | if (rc != 0) |
| 100 | { |
| 101 | BMCWEB_LOG_ERROR("Redfish event handler setup failed..."); |
| 102 | return rc; |
| 103 | } |
| 104 | #endif |
| 105 | |
Ed Tanous | 8db8374 | 2024-04-13 09:11:15 -0700 | [diff] [blame^] | 106 | if constexpr (bmcwebEnableTLS) |
| 107 | { |
| 108 | BMCWEB_LOG_INFO("Start Hostname Monitor Service..."); |
| 109 | crow::hostname_monitor::registerHostnameSignal(); |
| 110 | } |
Ed Tanous | 3cd7072 | 2024-04-06 09:24:01 -0700 | [diff] [blame] | 111 | |
| 112 | bmcweb::registerUserRemovedSignal(); |
| 113 | |
| 114 | app.run(); |
| 115 | io->run(); |
| 116 | |
| 117 | crow::connections::systemBus = nullptr; |
| 118 | |
| 119 | return 0; |
| 120 | } |