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