* 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 db25d38f4b
commit 774e789c8a

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
@ -86,21 +87,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()) {
$tmp = null;
if($cache->fetch('server_path', $tmp) && $tmp == $config['server_path']) {
$tmp = null;
if($cache->fetch('config_lua', $tmp) && $tmp) {
$config['lua'] = unserialize($tmp); $config['lua'] = unserialize($tmp);
/*if(isset($config['lua']['myaac'][0])) { $config_lua_reload = false;
foreach($config['lua']['myaac'] as $key => $value) }
$config[$key] = $value; }
}*/
} }
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);