Commit 54d091e6 authored by Dominik Hebeler's avatar Dominik Hebeler
Browse files

Ein Suchauftrag löst nun das Erstellen eines Logs aus, der Aufschluss darüber...

Ein Suchauftrag löst nun das Erstellen eines Logs aus, der Aufschluss darüber gibt, in welcher Sekunde wie viele
Worker aktiv waren.
parent 64c65621
......@@ -2,7 +2,12 @@
namespace App\Providers;
use Queue;
use Log;
use Redis;
use Illuminate\Support\ServiceProvider;
use Illuminate\Queue\Events\JobProcessed;
use Illuminate\Queue\Events\JobProcessing;
class AppServiceProvider extends ServiceProvider
{
......@@ -13,7 +18,34 @@ class AppServiceProvider extends ServiceProvider
*/
public function boot()
{
//
# Wir loggen im Redis-System für jede Sekunde des Tages, wie viele Worker aktiv am Laufen waren.
# Dies ist notwendig, damit wir mitbekommen können, ab welchem Zeitpunkt wir zu wenig Worker zur Verfügung haben.
Queue::before(function (JobProcessing $event) {
$this->begin = strtotime(date(DATE_RFC822, mktime(date("H"),date("i"), date("s"), date("m"), date("d"), date("Y"))));
});
Queue::after(function (JobProcessed $event) {
$this->end = strtotime(date(DATE_RFC822, mktime(date("H"),date("i"), date("s"), date("m"), date("d"), date("Y"))));
$expireAt = strtotime(date(DATE_RFC822, mktime(0,0,0, date("m"), date("d")+1, date("Y"))));
$redis = Redis::connection('redisLogs');
$p = getmypid();
$host = gethostname();
$redis->pipeline(function($pipe) use ($p, $expireAt, $host)
{
for( $i = $this->begin; $i <= $this->end; $i++)
{
$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);
}
}
});
});
}
/**
......
......@@ -1328,23 +1328,23 @@
},
{
"name": "swiftmailer/swiftmailer",
"version": "v5.4.2",
"version": "v5.4.3",
"source": {
"type": "git",
"url": "https://github.com/swiftmailer/swiftmailer.git",
"reference": "d8db871a54619458a805229a057ea2af33c753e8"
"reference": "4cc92842069c2bbc1f28daaaf1d2576ec4dfe153"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/swiftmailer/swiftmailer/zipball/d8db871a54619458a805229a057ea2af33c753e8",
"reference": "d8db871a54619458a805229a057ea2af33c753e8",
"url": "https://api.github.com/repos/swiftmailer/swiftmailer/zipball/4cc92842069c2bbc1f28daaaf1d2576ec4dfe153",
"reference": "4cc92842069c2bbc1f28daaaf1d2576ec4dfe153",
"shasum": ""
},
"require": {
"php": ">=5.3.3"
},
"require-dev": {
"mockery/mockery": "~0.9.1,<0.9.4"
"mockery/mockery": "~0.9.1"
},
"type": "library",
"extra": {
......@@ -1377,7 +1377,7 @@
"mail",
"mailer"
],
"time": "2016-05-01 08:45:47"
"time": "2016-07-08 11:51:25"
},
{
"name": "symfony/console",
......
Supports Markdown
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