* immediately reload config.lua when there's change in config.server_path detected

This commit is contained in:
slawkens1 2018-01-06 03:07:17 +01:00
parent 9c281511fa
commit 31537687c1

View File

@ -8,6 +8,7 @@
* @link http://my-aac.org * @link http://my-aac.org
*/ */
defined('MYAAC') or die('Direct access not allowed!'); defined('MYAAC') or die('Direct access not allowed!');
// load configuration // load configuration
require_once(BASE . 'config.php'); require_once(BASE . 'config.php');
if(file_exists(BASE . 'config.local.php')) // user customizations if(file_exists(BASE . 'config.local.php')) // user customizations
@ -87,21 +88,26 @@ if(isset($_REQUEST))
} }
// load otserv config file // load otserv config file
$tmp = ''; $config_lua_reload = true;
if($cache->enabled() && $cache->fetch('config_lua', $tmp)) { if($cache->enabled()) {
$config['lua'] = unserialize($tmp); $tmp = null;
/*if(isset($config['lua']['myaac'][0])) { if($cache->fetch('server_path', $tmp) && $tmp == $config['server_path']) {
foreach($config['lua']['myaac'] as $key => $value) $tmp = null;
$config[$key] = $value; if($cache->fetch('config_lua', $tmp) && $tmp) {
}*/ $config['lua'] = unserialize($tmp);
$config_lua_reload = false;
}
}
} }
else
{ if($config_lua_reload) {
$config['lua'] = load_config_lua($config['server_path'] . 'config.lua'); $config['lua'] = load_config_lua($config['server_path'] . 'config.lua');
// cache config // cache config
if($cache->enabled()) if($cache->enabled()) {
$cache->set('config_lua', serialize($config['lua']), 120); $cache->set('config_lua', serialize($config['lua']), 120);
$cache->set('server_path', $config['server_path']);
}
} }
unset($tmp); unset($tmp);