Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
Gelencsér Szabolcs
/
agentdriver
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Wiki
Members
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
6b928715
authored
Feb 10, 2014
by
Bach Dániel
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
stop celery on SIGINT
parent
da7e0963
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
20 additions
and
1 deletions
+20
-1
agentdriver.py
+20
-1
No files found.
agentdriver.py
View file @
6b928715
...
@@ -3,13 +3,30 @@ from twisted.internet import reactor, inotify
...
@@ -3,13 +3,30 @@ from twisted.internet import reactor, inotify
from
twisted.python
import
filepath
from
twisted.python
import
filepath
from
agentcelery
import
celery
from
agentcelery
import
celery
from
protocol
import
inotify_handler
from
protocol
import
inotify_handler
from
os
import
getenv
from
os
import
getenv
,
listdir
,
path
import
logging
import
logging
SOCKET_DIR
=
getenv
(
'SOCKET_DIR'
,
'/var/lib/libvirt/serial'
)
SOCKET_DIR
=
getenv
(
'SOCKET_DIR'
,
'/var/lib/libvirt/serial'
)
old_install_platform_tweaks
=
Worker
.
install_platform_tweaks
def
install_platform_tweaks
(
self
,
worker
):
self
.
worker
=
worker
old_install_platform_tweaks
(
self
,
worker
)
Worker
.
install_platform_tweaks
=
install_platform_tweaks
def
reactor_started
():
for
f
in
listdir
(
SOCKET_DIR
):
f
=
path
.
join
(
SOCKET_DIR
,
f
)
inotify_handler
(
None
,
filepath
.
FilePath
(
f
),
None
)
def
reactor_stopped
(
worker
):
worker
.
worker
.
stop
()
def
main
():
def
main
():
w
=
Worker
(
app
=
celery
,
concurrency
=
1
,
w
=
Worker
(
app
=
celery
,
concurrency
=
1
,
pool_cls
=
'threads'
,
pool_cls
=
'threads'
,
...
@@ -19,6 +36,8 @@ def main():
...
@@ -19,6 +36,8 @@ def main():
notifier
.
startReading
()
notifier
.
startReading
()
notifier
.
watch
(
filepath
.
FilePath
(
SOCKET_DIR
),
notifier
.
watch
(
filepath
.
FilePath
(
SOCKET_DIR
),
callbacks
=
[
inotify_handler
])
callbacks
=
[
inotify_handler
])
reactor
.
callWhenRunning
(
reactor_started
)
reactor
.
addSystemEventTrigger
(
"before"
,
"shutdown"
,
reactor_stopped
,
w
)
reactor
.
run
()
reactor
.
run
()
if
__name__
==
'__main__'
:
if
__name__
==
'__main__'
:
...
...
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