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" |
Ed Tanous | 3cd7072 | 2024-04-06 09:24:01 -0700 | [diff] [blame] | 6 | #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 Tanous | 5b90429 | 2024-04-16 11:10:17 -0700 | [diff] [blame] | 14 | #include "logging.hpp" |
Ed Tanous | 3cd7072 | 2024-04-06 09:24:01 -0700 | [diff] [blame] | 15 | #include "login_routes.hpp" |
Ed Tanous | 3cd7072 | 2024-04-06 09:24:01 -0700 | [diff] [blame] | 16 | #include "obmc_console.hpp" |
| 17 | #include "openbmc_dbus_rest.hpp" |
| 18 | #include "redfish.hpp" |
| 19 | #include "redfish_aggregator.hpp" |
Ed Tanous | 3cd7072 | 2024-04-06 09:24:01 -0700 | [diff] [blame] | 20 | #include "user_monitor.hpp" |
| 21 | #include "vm_websocket.hpp" |
| 22 | #include "webassets.hpp" |
| 23 | |
Ed Tanous | 3cd7072 | 2024-04-06 09:24:01 -0700 | [diff] [blame] | 24 | #include <boost/asio/io_context.hpp> |
| 25 | #include <sdbusplus/asio/connection.hpp> |
Ed Tanous | 5b90429 | 2024-04-16 11:10:17 -0700 | [diff] [blame] | 26 | |
| 27 | #include <memory> |
Ed Tanous | 3cd7072 | 2024-04-06 09:24:01 -0700 | [diff] [blame] | 28 | |
Ed Tanous | 3cd7072 | 2024-04-06 09:24:01 -0700 | [diff] [blame] | 29 | int 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 | |
Ed Tanous | 25b54db | 2024-04-17 15:40:31 -0700 | [diff] [blame^] | 40 | if constexpr (BMCWEB_STATIC_HOSTING) |
| 41 | { |
| 42 | crow::webassets::requestRoutes(app); |
| 43 | } |
Ed Tanous | 3cd7072 | 2024-04-06 09:24:01 -0700 | [diff] [blame] | 44 | |
Ed Tanous | 25b54db | 2024-04-17 15:40:31 -0700 | [diff] [blame^] | 45 | if constexpr (BMCWEB_KVM) |
| 46 | { |
| 47 | crow::obmc_kvm::requestRoutes(app); |
| 48 | } |
Ed Tanous | 3cd7072 | 2024-04-06 09:24:01 -0700 | [diff] [blame] | 49 | |
Ed Tanous | 25b54db | 2024-04-17 15:40:31 -0700 | [diff] [blame^] | 50 | if constexpr (BMCWEB_REDFISH) |
| 51 | { |
| 52 | redfish::RedfishService redfish(app); |
Ed Tanous | 3cd7072 | 2024-04-06 09:24:01 -0700 | [diff] [blame] | 53 | |
Ed Tanous | 25b54db | 2024-04-17 15:40:31 -0700 | [diff] [blame^] | 54 | // Create EventServiceManager instance and initialize Config |
| 55 | redfish::EventServiceManager::getInstance(&*io); |
Ed Tanous | 3cd7072 | 2024-04-06 09:24:01 -0700 | [diff] [blame] | 56 | |
Ed Tanous | 25b54db | 2024-04-17 15:40:31 -0700 | [diff] [blame^] | 57 | if constexpr (BMCWEB_REDFISH_AGGREGATION) |
| 58 | { |
| 59 | // Create RedfishAggregator instance and initialize Config |
| 60 | redfish::RedfishAggregator::getInstance(&*io); |
| 61 | } |
| 62 | } |
Ed Tanous | 3cd7072 | 2024-04-06 09:24:01 -0700 | [diff] [blame] | 63 | |
Ed Tanous | 25b54db | 2024-04-17 15:40:31 -0700 | [diff] [blame^] | 64 | if constexpr (BMCWEB_REST) |
| 65 | { |
| 66 | crow::dbus_monitor::requestRoutes(app); |
| 67 | crow::image_upload::requestRoutes(app); |
| 68 | crow::openbmc_mapper::requestRoutes(app); |
| 69 | } |
Ed Tanous | 3cd7072 | 2024-04-06 09:24:01 -0700 | [diff] [blame] | 70 | |
Ed Tanous | 25b54db | 2024-04-17 15:40:31 -0700 | [diff] [blame^] | 71 | if constexpr (BMCWEB_HOST_SERIAL_SOCKET) |
| 72 | { |
| 73 | crow::obmc_console::requestRoutes(app); |
| 74 | } |
Ed Tanous | 3cd7072 | 2024-04-06 09:24:01 -0700 | [diff] [blame] | 75 | |
Ed Tanous | 3cd7072 | 2024-04-06 09:24:01 -0700 | [diff] [blame] | 76 | crow::obmc_vm::requestRoutes(app); |
Ed Tanous | 3cd7072 | 2024-04-06 09:24:01 -0700 | [diff] [blame] | 77 | |
Ed Tanous | 25b54db | 2024-04-17 15:40:31 -0700 | [diff] [blame^] | 78 | if constexpr (BMCWEB_IBM_MANAGEMENT_CONSOLE) |
| 79 | { |
| 80 | crow::ibm_mc::requestRoutes(app); |
| 81 | } |
Ed Tanous | 3cd7072 | 2024-04-06 09:24:01 -0700 | [diff] [blame] | 82 | |
Ed Tanous | 25b54db | 2024-04-17 15:40:31 -0700 | [diff] [blame^] | 83 | if constexpr (BMCWEB_GOOGLE_API) |
| 84 | { |
| 85 | crow::google_api::requestRoutes(app); |
| 86 | } |
Ed Tanous | 3cd7072 | 2024-04-06 09:24:01 -0700 | [diff] [blame] | 87 | |
Ed Tanous | 3cd7072 | 2024-04-06 09:24:01 -0700 | [diff] [blame] | 88 | crow::login_routes::requestRoutes(app); |
| 89 | |
Ed Tanous | 25b54db | 2024-04-17 15:40:31 -0700 | [diff] [blame^] | 90 | if constexpr (BMCWEB_REDFISH_DBUS_LOG) |
Ed Tanous | 3cd7072 | 2024-04-06 09:24:01 -0700 | [diff] [blame] | 91 | { |
Ed Tanous | 25b54db | 2024-04-17 15:40:31 -0700 | [diff] [blame^] | 92 | int rc = redfish::EventServiceManager::startEventLogMonitor(*io); |
| 93 | if (rc != 0) |
| 94 | { |
| 95 | BMCWEB_LOG_ERROR("Redfish event handler setup failed..."); |
| 96 | return rc; |
| 97 | } |
Ed Tanous | 3cd7072 | 2024-04-06 09:24:01 -0700 | [diff] [blame] | 98 | } |
Ed Tanous | 3cd7072 | 2024-04-06 09:24:01 -0700 | [diff] [blame] | 99 | |
Ed Tanous | 25b54db | 2024-04-17 15:40:31 -0700 | [diff] [blame^] | 100 | if constexpr (!BMCWEB_INSECURE_DISABLE_SSL) |
Ed Tanous | 8db8374 | 2024-04-13 09:11:15 -0700 | [diff] [blame] | 101 | { |
| 102 | BMCWEB_LOG_INFO("Start Hostname Monitor Service..."); |
| 103 | crow::hostname_monitor::registerHostnameSignal(); |
| 104 | } |
Ed Tanous | 3cd7072 | 2024-04-06 09:24:01 -0700 | [diff] [blame] | 105 | |
| 106 | bmcweb::registerUserRemovedSignal(); |
| 107 | |
| 108 | app.run(); |
| 109 | io->run(); |
| 110 | |
| 111 | crow::connections::systemBus = nullptr; |
| 112 | |
| 113 | return 0; |
| 114 | } |