mirror of
https://github.com/SapphireServer/Sapphire.git
synced 2025-04-28 15:17:46 +00:00
everything should be working again...
This commit is contained in:
parent
03df0b242c
commit
bf0324cfea
4 changed files with 13 additions and 18 deletions
|
@ -49,25 +49,26 @@ void default_resource_send( const HttpServer& server, const shared_ptr< HttpServ
|
||||||
const shared_ptr< ifstream >& ifs );
|
const shared_ptr< ifstream >& ifs );
|
||||||
|
|
||||||
|
|
||||||
auto m_pConfig = std::make_shared< Sapphire::ConfigMgr >();
|
|
||||||
HttpServer server;
|
HttpServer server;
|
||||||
std::string configPath( "api.ini" );
|
std::string configPath( "api.ini" );
|
||||||
Sapphire::Common::Config::ApiConfig m_config;
|
Sapphire::Common::Config::ApiConfig m_config;
|
||||||
|
|
||||||
void reloadConfig()
|
void reloadConfig()
|
||||||
{
|
{
|
||||||
m_pConfig = std::make_shared< Sapphire::ConfigMgr >();
|
auto pConfig = std::make_shared< Sapphire::ConfigMgr >();
|
||||||
|
|
||||||
|
Logger::info( "Loading config " + configPath );
|
||||||
|
|
||||||
bool failedLoad = false;
|
bool failedLoad = false;
|
||||||
|
|
||||||
// load global cfg first
|
// load global cfg first
|
||||||
if( !m_pConfig->loadGlobalConfig( m_config.global ) )
|
if( !pConfig->loadGlobalConfig( m_config.global ) )
|
||||||
{
|
{
|
||||||
Logger::fatal( "Error loading config global.ini" );
|
Logger::fatal( "Error loading config global.ini" );
|
||||||
failedLoad = true;
|
failedLoad = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if( !m_pConfig->loadConfig( configPath ) )
|
if( !pConfig->loadConfig( configPath ) )
|
||||||
{
|
{
|
||||||
Logger::fatal( "Error loading config {0}", configPath );
|
Logger::fatal( "Error loading config {0}", configPath );
|
||||||
failedLoad = true;
|
failedLoad = true;
|
||||||
|
@ -75,12 +76,13 @@ void reloadConfig()
|
||||||
|
|
||||||
if( failedLoad )
|
if( failedLoad )
|
||||||
{
|
{
|
||||||
|
Logger::fatal( "If this is the first time starting the server, we've copied the default one for your editing pleasure." );
|
||||||
throw "Error loading config";
|
throw "Error loading config";
|
||||||
}
|
}
|
||||||
|
|
||||||
// setup api config
|
// setup api config
|
||||||
m_config.network.listenPort = m_pConfig->getValue< uint16_t >( "Network", "ListenPort", 80 );
|
m_config.network.listenPort = pConfig->getValue< uint16_t >( "Network", "ListenPort", 80 );
|
||||||
m_config.network.listenIP = m_pConfig->getValue< std::string >( "Network", "ListenIp", "0.0.0.0" );
|
m_config.network.listenIP = pConfig->getValue< std::string >( "Network", "ListenIp", "0.0.0.0" );
|
||||||
}
|
}
|
||||||
|
|
||||||
void print_request_info( shared_ptr< HttpServer::Request > request )
|
void print_request_info( shared_ptr< HttpServer::Request > request )
|
||||||
|
@ -90,14 +92,7 @@ void print_request_info( shared_ptr< HttpServer::Request > request )
|
||||||
|
|
||||||
bool loadSettings( int32_t argc, char* argv[] )
|
bool loadSettings( int32_t argc, char* argv[] )
|
||||||
{
|
{
|
||||||
Logger::info( "Loading config " + configPath );
|
reloadConfig();
|
||||||
|
|
||||||
if( !m_pConfig->loadConfig( configPath ) )
|
|
||||||
{
|
|
||||||
Logger::fatal( "Error loading config {0}", configPath );
|
|
||||||
Logger::fatal( "If this is the first time starting the server, we've copied the default one for your editing pleasure." );
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
std::vector< std::string > args( argv + 1, argv + argc );
|
std::vector< std::string > args( argv + 1, argv + argc );
|
||||||
for( size_t i = 0; i + 1 < args.size(); i += 2 )
|
for( size_t i = 0; i + 1 < args.size(); i += 2 )
|
||||||
|
@ -126,7 +121,7 @@ bool loadSettings( int32_t argc, char* argv[] )
|
||||||
auto dataPath = m_config.global.parameters.dataPath;
|
auto dataPath = m_config.global.parameters.dataPath;
|
||||||
if( !g_exdDataGen.init( dataPath ) )
|
if( !g_exdDataGen.init( dataPath ) )
|
||||||
{
|
{
|
||||||
Logger::fatal( "Error setting up generated EXD data. Make sure that DataPath is set correctly in config.ini" );
|
Logger::fatal( "Error setting up generated EXD data. Make sure that DataPath is set correctly in global.ini" );
|
||||||
Logger::fatal( "DataPath: {0}", dataPath );
|
Logger::fatal( "DataPath: {0}", dataPath );
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
|
@ -31,7 +31,7 @@ bool Sapphire::ConfigMgr::loadConfig( const std::string& configName )
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Sapphire::ConfigMgr::loadGlobalConfig( Common::Config::GlobalConfig& config, const string& configName )
|
bool Sapphire::ConfigMgr::loadGlobalConfig( Common::Config::GlobalConfig& config, const std::string& configName )
|
||||||
{
|
{
|
||||||
auto configFile = fs::path( fs::path( m_configFolderRoot ) / configName );
|
auto configFile = fs::path( fs::path( m_configFolderRoot ) / configName );
|
||||||
|
|
||||||
|
|
|
@ -17,7 +17,7 @@ namespace Sapphire
|
||||||
~ConfigMgr() = default;
|
~ConfigMgr() = default;
|
||||||
|
|
||||||
bool loadConfig( const std::string& configName );
|
bool loadConfig( const std::string& configName );
|
||||||
bool loadGlobalConfig( Common::Config::GlobalConfig& config, const string& configName = "global.ini" );
|
bool loadGlobalConfig( Common::Config::GlobalConfig& config, const std::string& configName = "global.ini" );
|
||||||
|
|
||||||
template<class T> struct always_false : std::false_type {};
|
template<class T> struct always_false : std::false_type {};
|
||||||
|
|
||||||
|
|
|
@ -130,7 +130,7 @@ void Sapphire::World::ServerMgr::run( int32_t argc, char* argv[] )
|
||||||
auto dataPath = m_config.global.parameters.dataPath;
|
auto dataPath = m_config.global.parameters.dataPath;
|
||||||
if( !pExdData->init( dataPath ) )
|
if( !pExdData->init( dataPath ) )
|
||||||
{
|
{
|
||||||
Logger::fatal( "Error setting up generated EXD data. Make sure that DataPath is set correctly in config.ini" );
|
Logger::fatal( "Error setting up generated EXD data. Make sure that DataPath is set correctly in global.ini" );
|
||||||
Logger::fatal( "DataPath: {0}", dataPath );
|
Logger::fatal( "DataPath: {0}", dataPath );
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue