Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
MetaGer
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
open-source
MetaGer
Commits
948afe28
Commit
948afe28
authored
2 years ago
by
Dominik Hebeler
Browse files
Options
Downloads
Patches
Plain Diff
request fetcher now waits for fpm to stop before shutting down
parent
9602eb01
No related branches found
Branches containing commit
No related tags found
1 merge request
!1995
Resolve "Make MetaGer Pods shutdown gracefully"
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
metager/app/Console/Commands/FPMGracefulStop.php
+14
-2
14 additions, 2 deletions
metager/app/Console/Commands/FPMGracefulStop.php
metager/app/Console/Commands/RequestFetcher.php
+3
-3
3 additions, 3 deletions
metager/app/Console/Commands/RequestFetcher.php
with
17 additions
and
5 deletions
metager/app/Console/Commands/FPMGracefulStop.php
+
14
−
2
View file @
948afe28
...
...
@@ -2,10 +2,13 @@
namespace
App\Console\Commands
;
use
ErrorException
;
use
Illuminate\Console\Command
;
use
Illuminate\Support\Facades\Redis
;
class
FPMGracefulStop
extends
Command
{
const
REDIS_FPM_STOPPED_KEY
=
"fpm_stopped"
;
/**
* The name and signature of the console command.
*
...
...
@@ -33,6 +36,11 @@ class FPMGracefulStop extends Command
}
while
(
$active_fpm_processes
===
null
||
$active_fpm_processes
>
1
);
$this
->
info
(
"Only one FPM process left. Ready to stop fpm..."
);
// The Request fetcher won't stop before FPM is not stopped with processing requests
// because there could be last jobs flying in
// This Redis Value will tell him that it's good to stop
Redis
::
set
(
self
::
REDIS_FPM_STOPPED_KEY
,
"true"
);
$this
->
info
(
"Set Redis Key"
);
return
0
;
}
...
...
@@ -51,8 +59,12 @@ class FPMGracefulStop extends Command
"header"
=>
"Authorization: Basic
$auth
"
,
],
]);
$fpm_info
=
\file_get_contents
(
$url
,
false
,
$context
);
try
{
$fpm_info
=
\file_get_contents
(
$url
,
false
,
$context
);
}
catch
(
ErrorException
$e
)
{
// Webserver could not be reached. Probably already shut down so there are no active connections anyways
return
0
;
}
if
(
$fpm_info
!==
false
)
{
$fpm_info
=
\json_decode
(
$fpm_info
);
}
else
{
...
...
This diff is collapsed.
Click to expand it.
metager/app/Console/Commands/RequestFetcher.php
+
3
−
3
View file @
948afe28
...
...
@@ -84,7 +84,8 @@ class RequestFetcher extends Command
if
(
$newJobs
===
0
&&
$answersRead
===
0
)
{
usleep
(
10
*
1000
);
}
if
(
!
$this
->
shouldRun
&&
$operationsRunning
===
0
)
{
if
(
!
$this
->
shouldRun
&&
$operationsRunning
===
0
&&
Redis
::
get
(
FPMGracefulStop
::
REDIS_FPM_STOPPED_KEY
)
!==
NULL
)
{
break
;
}
}
...
...
@@ -234,8 +235,7 @@ class RequestFetcher extends Command
public
function
sig_handler
(
$sig
)
{
$this
->
info
(
"Received Shutdown signal"
);
$this
->
shouldRun
=
false
;
echo
(
"Terminating Process
\n
"
);
$this
->
info
(
"Terminating Process
\n
"
);
}
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment