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
Klaus Wölfel
slapos.toolbox
Commits
05618968
Commit
05618968
authored
Sep 01, 2014
by
Nicolas Wavrant
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
runner: make sup_process.py pylint compliant
parent
cbd211cd
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
25 additions
and
1 deletion
+25
-1
slapos/runner/sup_process.py
slapos/runner/sup_process.py
+25
-1
No files found.
slapos/runner/sup_process.py
View file @
05618968
# pylint: disable-msg=W0311,C0103
import
os
import
os
import
signal
import
signal
import
time
import
time
...
@@ -9,12 +11,19 @@ import xmlrpclib
...
@@ -9,12 +11,19 @@ import xmlrpclib
def
isRunning
(
config
,
process
):
def
isRunning
(
config
,
process
):
"""
Ask supervisor if given process is currently running
"""
server
=
xmlrpclib
.
Server
(
config
[
'supervisord_server'
])
server
=
xmlrpclib
.
Server
(
config
[
'supervisord_server'
])
state
=
server
.
supervisor
.
getProcessInfo
(
process
)[
'state'
]
state
=
server
.
supervisor
.
getProcessInfo
(
process
)[
'state'
]
return
(
True
if
state
in
(
10
,
20
)
else
False
)
return
(
True
if
state
in
(
10
,
20
)
else
False
)
def
killRunningProcess
(
config
,
process
,
sig
=
signal
.
SIGTERM
):
def
killRunningProcess
(
config
,
process
,
sig
=
signal
.
SIGTERM
):
"""
Send signal "sig" to given process.
Default signal sent is SIGTERM
"""
server
=
xmlrpclib
.
Server
(
config
[
'supervisord_server'
])
server
=
xmlrpclib
.
Server
(
config
[
'supervisord_server'
])
pid
=
server
.
supervisor
.
getProcessInfo
(
process
)[
'pid'
]
pid
=
server
.
supervisor
.
getProcessInfo
(
process
)[
'pid'
]
if
pid
!=
0
:
if
pid
!=
0
:
...
@@ -22,21 +31,30 @@ def killRunningProcess(config, process, sig=signal.SIGTERM):
...
@@ -22,21 +31,30 @@ def killRunningProcess(config, process, sig=signal.SIGTERM):
def
returnCode
(
config
,
process
):
def
returnCode
(
config
,
process
):
"""
Get the returned code of the last run of given process
"""
server
=
xmlrpclib
.
Server
(
config
[
'supervisord_server'
])
server
=
xmlrpclib
.
Server
(
config
[
'supervisord_server'
])
code
=
server
.
supervisor
.
getProcessInfo
(
process
)[
'exitstatus'
]
code
=
server
.
supervisor
.
getProcessInfo
(
process
)[
'exitstatus'
]
return
code
return
code
def
runProcess
(
config
,
process
):
def
runProcess
(
config
,
process
):
"""
Start a process registered by supervisor
"""
server
=
xmlrpclib
.
Server
(
config
[
'supervisord_server'
])
server
=
xmlrpclib
.
Server
(
config
[
'supervisord_server'
])
server
.
supervisor
.
startProcess
(
process
)
server
.
supervisor
.
startProcess
(
process
)
def
runProcesses
(
config
,
processes
):
def
runProcesses
(
config
,
processes
):
"""
Start by supervisor a list of given processes, one by one
"""
server
=
xmlrpclib
.
Server
(
config
[
'supervisord_server'
])
server
=
xmlrpclib
.
Server
(
config
[
'supervisord_server'
])
for
proc
in
processes
:
for
proc
in
processes
:
server
.
supervisor
.
startProcess
(
proc
)
server
.
supervisor
.
startProcess
(
proc
)
waitForProcessEnd
(
proc
)
waitForProcessEnd
(
config
,
proc
)
def
stopProcess
(
config
,
process
):
def
stopProcess
(
config
,
process
):
...
@@ -49,12 +67,18 @@ def stopProcess(config, process):
...
@@ -49,12 +67,18 @@ def stopProcess(config, process):
def
stopProcesses
(
config
,
processes
):
def
stopProcesses
(
config
,
processes
):
"""
Stop a list of processes
"""
server
=
xmlrpclib
.
Server
(
config
[
'supervisord_server'
])
server
=
xmlrpclib
.
Server
(
config
[
'supervisord_server'
])
for
proc
in
processes
:
for
proc
in
processes
:
server
.
supervisor
.
stopProcess
(
proc
)
server
.
supervisor
.
stopProcess
(
proc
)
def
waitForProcessEnd
(
config
,
process
):
def
waitForProcessEnd
(
config
,
process
):
"""
Block program's execution until given process quits Running state
"""
server
=
xmlrpclib
.
Server
(
config
[
'supervisord_server'
])
server
=
xmlrpclib
.
Server
(
config
[
'supervisord_server'
])
while
True
:
while
True
:
state
=
server
.
supervisor
.
getProcessInfo
(
process
)[
'state'
]
state
=
server
.
supervisor
.
getProcessInfo
(
process
)[
'state'
]
...
...
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