MCPcopy Create free account
hub / github.com/SapphireServer/Sapphire / reloadConfig

Function reloadConfig

src/api/main.cpp:58–88  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

56Sapphire::Common::Config::ApiConfig m_config;
57
58void reloadConfig()
59{
60 auto pConfig = std::make_shared< Sapphire::Common::ConfigMgr >();
61
62 Logger::info( "Loading config " + configPath );
63
64 bool failedLoad = false;
65
66 // load global cfg first
67 if( !pConfig->loadGlobalConfig( m_config.global ) )
68 {
69 Logger::fatal( "Error loading config global.ini" );
70 failedLoad = true;
71 }
72
73 if( !pConfig->loadConfig( configPath ) )
74 {
75 Logger::fatal( "Error loading config {0}", configPath );
76 failedLoad = true;
77 }
78
79 if( failedLoad )
80 {
81 Logger::fatal( "If this is the first time starting the server, we've copied the default configs for your editing pleasure." );
82 throw "Error loading config";
83 }
84
85 // setup api config
86 m_config.network.listenPort = pConfig->getValue< uint16_t >( "Network", "ListenPort", 80 );
87 m_config.network.listenIP = pConfig->getValue< std::string >( "Network", "ListenIp", "0.0.0.0" );
88}
89
90void print_request_info( shared_ptr< HttpServer::Request > request )
91{

Callers 1

loadSettingsFunction · 0.85

Calls 2

loadGlobalConfigMethod · 0.80
loadConfigMethod · 0.80

Tested by

no test coverage detected