Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
S
slapos.toolbox
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
Lu Xu
slapos.toolbox
Commits
65257733
Commit
65257733
authored
Apr 25, 2014
by
Cédric Le Ninivin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
runner: introduce function to test running process from pidfile
parent
28321c70
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
18 additions
and
1 deletion
+18
-1
slapos/runner/process.py
slapos/runner/process.py
+15
-0
slapos/runner/utils.py
slapos/runner/utils.py
+3
-1
No files found.
slapos/runner/process.py
View file @
65257733
...
@@ -104,3 +104,18 @@ def setHandler(sig_list=None):
...
@@ -104,3 +104,18 @@ def setHandler(sig_list=None):
sig_list
=
[
signal
.
SIGTERM
]
sig_list
=
[
signal
.
SIGTERM
]
for
sig
in
sig_list
:
for
sig
in
sig_list
:
signal
.
signal
(
sig
,
handler
)
signal
.
signal
(
sig
,
handler
)
def
isPidFileProcessRunning
(
pidfile
):
"""
Test if the pidfile exist and if the process is still active
"""
if
os
.
path
.
exists
(
pidfile
):
try
:
pid
=
int
(
open
(
pidfile
,
'r'
).
readline
())
except
ValueError
:
pid
=
None
# XXX This could use psutil library.
if
pid
and
os
.
path
.
exists
(
"/proc/%s"
%
pid
):
return
True
return
False
slapos/runner/utils.py
View file @
65257733
...
@@ -20,7 +20,7 @@ from flask import jsonify
...
@@ -20,7 +20,7 @@ from flask import jsonify
from
slapos.runner.gittools
import
cloneRepo
from
slapos.runner.gittools
import
cloneRepo
from
slapos.runner.process
import
Popen
,
isRunning
,
killRunningProcess
from
slapos.runner.process
import
Popen
,
isRunning
,
killRunningProcess
,
isPidFileProcessRunning
from
slapos.htpasswd
import
HtpasswdFile
from
slapos.htpasswd
import
HtpasswdFile
import
slapos.slap
import
slapos.slap
...
@@ -278,6 +278,8 @@ def runSoftwareWithLock(config, lock=True):
...
@@ -278,6 +278,8 @@ def runSoftwareWithLock(config, lock=True):
return
False
return
False
slapgrid_pid
=
os
.
path
.
join
(
config
[
'run_dir'
],
'slapgrid-sr.pid'
)
slapgrid_pid
=
os
.
path
.
join
(
config
[
'run_dir'
],
'slapgrid-sr.pid'
)
if
isPidFileProcessRunning
(
slapgrid_pid
):
return
False
if
not
os
.
path
.
exists
(
config
[
'software_root'
]):
if
not
os
.
path
.
exists
(
config
[
'software_root'
]):
os
.
mkdir
(
config
[
'software_root'
])
os
.
mkdir
(
config
[
'software_root'
])
stopProxy
(
config
)
stopProxy
(
config
)
...
...
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