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
Guillaume Hervier
slapos.toolbox
Commits
d070a9f8
Commit
d070a9f8
authored
May 31, 2017
by
Rafael Monnerat
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
apache_mpm_watchdog: Fixes for argparse usage and timeout.
parent
5f92ce8a
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
6 additions
and
5 deletions
+6
-5
slapos/promise/apache_mpm_watchdog/__init__.py
slapos/promise/apache_mpm_watchdog/__init__.py
+6
-5
No files found.
slapos/promise/apache_mpm_watchdog/__init__.py
View file @
d070a9f8
...
...
@@ -5,6 +5,7 @@ import os
import
psutil
import
json
import
time
import
argparse
search_pid_regex
=
r"</td><td.*?>(.+?)</td><td>yes \
(old ge
n\
)</
td>"
...
...
@@ -43,7 +44,7 @@ def getServerStatus(url, user, password):
except
requests
.
exceptions
.
ConnectionError
:
return
def
watchServerStatus
(
pid_dict
,
server_status
):
def
watchServerStatus
(
pid_dict
,
server_status
,
timeout
):
_pid_dict
=
pid_dict
.
copy
()
for
i
in
re
.
findall
(
search_pid_regex
,
server_status
):
try
:
...
...
@@ -53,8 +54,8 @@ def watchServerStatus(pid_dict, server_status):
# Ensure the process is actually an apache
if
process
.
cmdline
()[
0
].
endswith
(
"/httpd"
):
pid_dict
.
setdefault
(
i
,
time
.
time
()
+
timeout
)
if
pid_dict
[
i
]
<
time
.
time
():
_
pid_dict
.
setdefault
(
i
,
time
.
time
()
+
timeout
)
if
_
pid_dict
[
i
]
<
time
.
time
():
print
"Sending signal -%s to %s"
%
(
signal
.
SIGKILL
,
i
)
os
.
kill
(
int
(
i
),
signal
.
SIGKILL
)
...
...
@@ -63,7 +64,7 @@ def watchServerStatus(pid_dict, server_status):
def
main
():
parser
=
argparse
.
ArgumentParser
()
# Address to ping to
parser
.
add_argument
(
"-
u"
,
"-
-url"
,
required
=
True
)
parser
.
add_argument
(
"--url"
,
required
=
True
)
# Force use ipv4 protocol
parser
.
add_argument
(
"-u"
,
"--user"
)
parser
.
add_argument
(
"-p"
,
"--password"
)
...
...
@@ -79,7 +80,7 @@ def main():
if
server_status
is
None
:
raise
ValueError
(
"Couldn't connect to server status page"
)
pid_dict
=
watchServerStatus
(
pid_dict
,
server_status
)
pid_dict
=
watchServerStatus
(
pid_dict
,
server_status
,
args
.
timeout
)
writeJSONFile
(
pid_dict
,
args
.
db
)
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