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
Lisa Casino
slapos.toolbox
Commits
84bba7b6
Commit
84bba7b6
authored
Aug 28, 2014
by
Nicolas Wavrant
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
runner: sup_process library upgraded (new functions, fixes)
parent
de01a150
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
20 additions
and
2 deletions
+20
-2
slapos/runner/sup_process.py
slapos/runner/sup_process.py
+20
-2
No files found.
slapos/runner/sup_process.py
View file @
84bba7b6
import
os
import
signal
import
time
import
time
import
xmlrpclib
import
xmlrpclib
...
@@ -7,10 +9,18 @@ from supervisor import childutils
...
@@ -7,10 +9,18 @@ from supervisor import childutils
# It aims to replace the file "process.py"
# It aims to replace the file "process.py"
# For the moment, we keep both for compatibility
# For the moment, we keep both for compatibility
def
isRunning
(
config
,
process
):
def
isRunning
(
config
,
process
):
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
==
20
else
False
)
return
(
True
if
state
in
(
10
,
20
)
else
False
)
def
killRunningProcess
(
config
,
process
,
sig
=
signal
.
SIGTERM
):
server
=
xmlrpclib
.
Server
(
config
[
'supervisord_server'
])
pid
=
server
.
supervisor
.
getProcessInfo
(
process
)[
'pid'
]
if
pid
!=
0
:
os
.
kill
(
pid
,
sig
)
def
returnCode
(
config
,
process
):
def
returnCode
(
config
,
process
):
...
@@ -31,6 +41,12 @@ def runProcesses(config, processes):
...
@@ -31,6 +41,12 @@ def runProcesses(config, processes):
waitForProcessEnd
(
proc
)
waitForProcessEnd
(
proc
)
def
stopIfRunning
(
config
,
process
):
if
isRunning
(
config
,
process
):
server
=
xmlrpclib
.
Server
(
config
[
'supervisord_server'
])
slapos
.
stopProcess
(
process
)
def
stopProcess
(
config
,
process
):
def
stopProcess
(
config
,
process
):
server
=
xmlrpclib
.
Server
(
config
[
'supervisord_server'
])
server
=
xmlrpclib
.
Server
(
config
[
'supervisord_server'
])
server
.
supervisor
.
stopProcess
(
process
)
server
.
supervisor
.
stopProcess
(
process
)
...
@@ -47,5 +63,7 @@ def waitForProcessEnd(config, process):
...
@@ -47,5 +63,7 @@ def waitForProcessEnd(config, process):
while
True
:
while
True
:
state
=
server
.
supervisor
.
getProcessInfo
(
process
)[
'state'
]
state
=
server
.
supervisor
.
getProcessInfo
(
process
)[
'state'
]
if
state
==
20
:
if
state
==
20
:
time
.
sleep
(
5
)
time
.
sleep
(
3
)
else
:
return
True
return
False
return
False
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