Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
slapos-caddy
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
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Guillaume Hervier
slapos-caddy
Commits
b3b14875
Commit
b3b14875
authored
Jun 10, 2011
by
Łukasz Nowak
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Monitor backgrounded process.
parent
ce0e1438
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
28 additions
and
7 deletions
+28
-7
slapos/recipe/zabbixagent/svcdaemon.py
slapos/recipe/zabbixagent/svcdaemon.py
+28
-7
No files found.
slapos/recipe/zabbixagent/svcdaemon.py
View file @
b3b14875
...
@@ -4,22 +4,39 @@ import time
...
@@ -4,22 +4,39 @@ import time
import
signal
import
signal
import
sys
import
sys
def
get_pid
(
filename
):
pid
=
None
if
os
.
path
.
exists
(
filename
):
data
=
open
(
pid_file
).
read
()
try
:
pid
=
int
(
data
)
except
ValueError
:
pass
return
pid
pid_file
=
None
pid_file
=
None
def
sig_handler
(
s
,
frame
):
def
sig_handler
(
s
,
frame
):
print
"Killing on signal %s:"
%
s
,
print
"Killing on signal %s:"
%
s
,
global
pid_file
global
pid_file
if
pid_file
is
not
None
:
if
pid_file
is
not
None
:
if
os
.
path
.
exists
(
pid_file
):
pid
=
get_pid
(
pid_file
)
pid
=
int
(
open
(
pid_file
).
read
())
if
pid
is
not
None
:
print
'pid %s with SIGTERM...'
%
pid
,
os
.
kill
(
pid
,
signal
.
SIGTERM
)
os
.
kill
(
pid
,
signal
.
SIGTERM
)
if
os
.
kill
(
pid
,
0
):
try
:
os
.
kill
(
pid
,
0
)
except
Exception
:
pass
else
:
time
.
sleep
(
5
)
time
.
sleep
(
5
)
if
os
.
kill
(
pid
,
0
):
try
:
os
.
kill
(
pid
,
0
)
except
Exception
:
pass
else
:
print
'with SIGKILL...'
,
print
'with SIGKILL...'
,
os
.
kill
(
pid
,
signal
.
SIGKILL
)
os
.
kill
(
pid
,
signal
.
SIGKILL
)
else
:
else
:
print
'no pid file %r, nothing to do...'
%
pid_file
,
raise
ValueError
(
'Pid is none.'
)
print
'done.'
print
'done.'
sys
.
exit
(
0
)
sys
.
exit
(
0
)
...
@@ -36,4 +53,8 @@ def svcdaemon(args):
...
@@ -36,4 +53,8 @@ def svcdaemon(args):
subprocess
.
check_call
(
real_binary
)
subprocess
.
check_call
(
real_binary
)
print
'Started %r'
%
real_binary
print
'Started %r'
%
real_binary
while
True
:
while
True
:
time
.
sleep
(
2
)
time
.
sleep
(
5
)
pid
=
get_pid
(
pid_file
)
if
pid
is
None
:
raise
ValueError
(
'Pid is none'
)
os
.
kill
(
pid
,
0
)
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