Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
S
slapos.core
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Xavier Thompson
slapos.core
Commits
65556465
Commit
65556465
authored
Dec 16, 2022
by
Xavier Thompson
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
grid/utils.py: Detect too old existing process
parent
df92f04d
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
28 additions
and
4 deletions
+28
-4
slapos/grid/utils.py
slapos/grid/utils.py
+28
-4
No files found.
slapos/grid/utils.py
View file @
65556465
...
...
@@ -92,6 +92,10 @@ LOCALE_ENVIRONMENT_REMOVE_LIST = [
'LC_TIME'
,
]
SLAPGRID_TIMEOUT
=
60
*
60
*
2
SLAPGRID_KILL_TIMEOUT
=
60
*
60
*
24
class
LineLogger
(
object
):
"""
...
...
@@ -249,7 +253,10 @@ def getCleanEnvironment(logger, home_path='/tmp'):
def
setRunning
(
logger
,
pidfile
):
"""Creates a pidfile. If a pidfile already exists, we exit"""
"""
Creates a pidfile. If a pidfile already exists, we exit.
If the pid file is too old, we report a stall.
"""
if
os
.
path
.
exists
(
pidfile
):
try
:
with
open
(
pidfile
,
'r'
)
as
f
:
...
...
@@ -266,8 +273,25 @@ def setRunning(logger, pidfile):
'Error getting information about process with pid %s'
,
pid
,
exc_info
=
True
)
if
is_slapos_running
:
logger
.
info
(
'New slapos process started, but another slapos '
'process is aleady running with pid %s, exiting.'
,
pid
)
creation_time
=
process
.
create_time
()
running_time
=
time
.
time
()
-
creation_time
if
running_time
>
SLAPGRID_KILL_TIMEOUT
:
logger
.
warning
(
"Existing slapos process has been running too long "
"(%ds > %d), killing it"
,
running_time
,
SLAPGRID_KILL_TIMEOUT
)
killProcessTree
(
pid
,
logger
)
elif
running_time
>
SLAPGRID_TIMEOUT
:
logger
.
warning
(
"Existing slapos process has been running too long "
"(%ds > %d), reporting likely problem"
,
running_time
,
SLAPGRID_TIMEOUT
)
# report to master ?
else
:
logger
.
info
(
"New slapos process started, but another slapos "
"process is aleady running with pid %s for %ds, exiting."
,
pid
,
running_time
)
sys
.
exit
(
10
)
logger
.
info
(
'Existing pid file %r was stale, overwritten'
,
pidfile
)
# Start new process
...
...
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