Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
open-source
MetaGer
Commits
f71f0b1e
Commit
f71f0b1e
authored
Jul 18, 2016
by
Dominik Hebeler
Browse files
Wenn keine Redis-Verbindung zum Logs-Server aufgebaut werden kann, stürzt das Skript nicht mehr ab
parent
17444e92
Changes
2
Hide whitespace changes
Inline
Side-by-side
app/MetaGer.php
View file @
f71f0b1e
...
...
@@ -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
;
}
}
...
...
app/Providers/AppServiceProvider.php
View file @
f71f0b1e
...
...
@@ -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
;
}
});
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment