|
@@ -71,7 +71,8 @@ function subscribe_message(&$quit, &$redis, $channels,$looper)
|
|
|
continue;
|
|
|
}
|
|
|
|
|
|
- $ret = $redis->subscribe($channels,function ($redis,$channel,$msg) use(&$quit,$looper)
|
|
|
+ $fLoading = false;
|
|
|
+ $ret = $redis->subscribe($channels,function ($redis,$channel,$msg) use(&$quit,$looper,&$fLoading)
|
|
|
{
|
|
|
Log::record("channel={$channel} msg={$msg}",Log::DEBUG);
|
|
|
$content = json_decode($msg,true);
|
|
@@ -81,23 +82,29 @@ function subscribe_message(&$quit, &$redis, $channels,$looper)
|
|
|
if($quit) return;
|
|
|
|
|
|
if($type == 'channel' || $type == 'merchant') {
|
|
|
+ $fLoading = true;
|
|
|
$looper->pause();
|
|
|
Log::record("start load.....",Log::DEBUG);
|
|
|
refill\RefillFactory::instance()->load();
|
|
|
Log::record("fini load.....",Log::DEBUG);
|
|
|
$looper->resume();
|
|
|
+ $fLoading = false;
|
|
|
}
|
|
|
- elseif($type == 'ratio') {
|
|
|
- $ins = Cache::getInstance('cacheredis');
|
|
|
- $val = $ins->get_org('channel_ratios');
|
|
|
-
|
|
|
- if(empty($val)) return;
|
|
|
- $val = json_decode($val,true);
|
|
|
- if(empty($val)) return;
|
|
|
- $ratios = $val['ratios'];
|
|
|
- if(empty($ratios)) return;
|
|
|
-
|
|
|
- refill\RefillFactory::instance()->UpdateRatio($ratios);
|
|
|
+ elseif($type == 'ratio')
|
|
|
+ {
|
|
|
+ if($fLoading == false)
|
|
|
+ {
|
|
|
+ $ins = Cache::getInstance('cacheredis');
|
|
|
+ $val = $ins->get_org('channel_ratios');
|
|
|
+
|
|
|
+ if(empty($val)) return;
|
|
|
+ $val = json_decode($val,true);
|
|
|
+ if(empty($val)) return;
|
|
|
+ $ratios = $val['ratios'];
|
|
|
+ if(empty($ratios)) return;
|
|
|
+
|
|
|
+ refill\RefillFactory::instance()->UpdateRatio($ratios);
|
|
|
+ }
|
|
|
}
|
|
|
else {
|
|
|
Log::record("subscribe_message dont not handle mgs:{$channel}-{$type}",Log::DEBUG);
|
|
@@ -121,6 +128,7 @@ for ($i = 0; $i < $process_count;$i++)
|
|
|
$process = new Swoole\Process(function(Swoole\Process $worker)
|
|
|
{
|
|
|
Base::run_util();
|
|
|
+ refill\RefillFactory::instance();
|
|
|
set_error_handler('handle_error');
|
|
|
|
|
|
$sub_quit = false;
|