Commit f71f0b1e authored by Dominik Hebeler's avatar Dominik Hebeler
Browse files

Wenn keine Redis-Verbindung zum Logs-Server aufgebaut werden kann, stürzt das Skript nicht mehr ab

parent 17444e92
......@@ -152,7 +152,7 @@ class MetaGer
private function createLogs()
{
$redis = Redis::connection('redisLogs');
if( $redis )
try
{
$logEntry = "";
$logEntry .= "[" . date(DATE_RFC822, mktime(date("H"),date("i"), date("s"), date("m"), date("d"), date("Y"))) . "]";
......@@ -176,6 +176,9 @@ class MetaGer
$logEntry .= " iter= mm= time=" . round((microtime(true)-$this->starttime), 2) . " serv=" . $this->fokus . " which= hits= stringSearch= QuickTips= SSS= check=";
$logEntry .= " search=" . $this->eingabe;
$redis->rpush('logs.search', $logEntry);
}catch( \Exception $e)
{
return;
}
}
......
......@@ -28,25 +28,32 @@ class AppServiceProvider extends ServiceProvider
$today = strtotime(date(DATE_RFC822, mktime(0,0,0, date("m"), date("d"), date("Y"))));
$end = strtotime(date(DATE_RFC822, mktime(date("H"),date("i"), date("s"), date("m"), date("d"), date("Y")))) - $today;
$expireAt = strtotime(date(DATE_RFC822, mktime(0,0,0, date("m"), date("d")+1, date("Y"))));
$redis = Redis::connection('redisLogs');
$p = getmypid();
$host = gethostname();
$begin = $this->begin - $today;
$redis->pipeline(function($pipe) use ($p, $expireAt, $host, $begin, $end)
{
for( $i = $begin; $i <= $end; $i++)
try{
$redis = Redis::connection('redisLogs');
if( !$redis )
return;
$p = getmypid();
$host = gethostname();
$begin = $this->begin - $today;
$redis->pipeline(function($pipe) use ($p, $expireAt, $host, $begin, $end)
{
$pipe->sadd("logs.worker.$host.$i", strval($p));
$pipe->expire("logs.worker.$host.$i", 10);
$pipe->eval("redis.call('hset', 'logs.worker.$host', '$i', redis.call('scard', 'logs.worker.$host.$i'))", 0);
$pipe->sadd("logs.worker", $host);
if( date("H") !== 0 )
for( $i = $begin; $i <= $end; $i++)
{
$pipe->expire("logs.worker.$host", $expireAt);
$pipe->expire("logs.worker", $expireAt);
$pipe->sadd("logs.worker.$host.$i", strval($p));
$pipe->expire("logs.worker.$host.$i", 10);
$pipe->eval("redis.call('hset', 'logs.worker.$host', '$i', redis.call('scard', 'logs.worker.$host.$i'))", 0);
$pipe->sadd("logs.worker", $host);
if( date("H") !== 0 )
{
$pipe->expire("logs.worker.$host", $expireAt);
$pipe->expire("logs.worker", $expireAt);
}
}
}
});
});
}catch( \Exception $e)
{
return;
}
});
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment