#include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #ifdef BMCWEB_ENABLE_VM_NBDPROXY #include #endif constexpr int defaultPort = 18080; inline void setupSocket(crow::App& app) { int listenFd = sd_listen_fds(0); if (1 == listenFd) { BMCWEB_LOG_INFO << "attempting systemd socket activation"; if (sd_is_socket_inet(SD_LISTEN_FDS_START, AF_UNSPEC, SOCK_STREAM, 1, 0)) { BMCWEB_LOG_INFO << "Starting webserver on socket handle " << SD_LISTEN_FDS_START; app.socket(SD_LISTEN_FDS_START); } else { BMCWEB_LOG_INFO << "bad incoming socket, starting webserver on port " << defaultPort; app.port(defaultPort); } } else { BMCWEB_LOG_INFO << "Starting webserver on port " << defaultPort; app.port(defaultPort); } } int main(int /*argc*/, char** /*argv*/) { crow::Logger::setLogLevel(crow::LogLevel::Debug); auto io = std::make_shared(); App app(io); crow::connections::systemBus = std::make_shared(*io); // Static assets need to be initialized before Authorization, because auth // needs to build the whitelist from the static routes #ifdef BMCWEB_ENABLE_STATIC_HOSTING crow::webassets::requestRoutes(app); #endif #ifdef BMCWEB_ENABLE_KVM crow::obmc_kvm::requestRoutes(app); #endif #ifdef BMCWEB_ENABLE_REDFISH redfish::requestRoutes(app); redfish::RedfishService redfish(app); // Create EventServiceManager instance and initialize Config redfish::EventServiceManager::getInstance(); #endif #ifdef BMCWEB_ENABLE_DBUS_REST crow::dbus_monitor::requestRoutes(app); crow::image_upload::requestRoutes(app); crow::openbmc_mapper::requestRoutes(app); #endif #ifdef BMCWEB_ENABLE_HOST_SERIAL_WEBSOCKET crow::obmc_console::requestRoutes(app); #endif #ifdef BMCWEB_ENABLE_VM_WEBSOCKET crow::obmc_vm::requestRoutes(app); #endif #ifdef BMCWEB_ENABLE_IBM_MANAGEMENT_CONSOLE crow::ibm_mc::requestRoutes(app); crow::ibm_mc_lock::Lock::getInstance(); #endif #ifdef BMCWEB_ENABLE_GOOGLE_API crow::google_api::requestRoutes(app); #endif if (bmcwebInsecureDisableXssPrevention) { cors_preflight::requestRoutes(app); } crow::login_routes::requestRoutes(app); setupSocket(app); #ifdef BMCWEB_ENABLE_VM_NBDPROXY crow::nbd_proxy::requestRoutes(app); #endif #ifndef BMCWEB_ENABLE_REDFISH_DBUS_LOG_ENTRIES int rc = redfish::EventServiceManager::startEventLogMonitor(*io); if (rc) { BMCWEB_LOG_ERROR << "Redfish event handler setup failed..."; return rc; } #endif #ifdef BMCWEB_ENABLE_SSL BMCWEB_LOG_INFO << "Start Hostname Monitor Service..."; crow::hostname_monitor::registerHostnameSignal(); #endif app.run(); io->run(); crow::connections::systemBus.reset(); return 0; }