Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
CIRCLE
/
dnsdriver
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
8384d8ed
authored
Nov 05, 2018
by
Czémán Arnold
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
rework
parent
67944074
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
6 additions
and
5 deletions
+6
-5
dnscelery.py
+6
-5
No files found.
dnscelery.py
View file @
8384d8ed
from
os
import
getenv
from
os
import
getenv
,
path
import
subprocess
import
subprocess
from
kombu
import
Queue
,
Exchange
from
kombu
import
Queue
,
Exchange
...
@@ -8,6 +8,7 @@ from celery import Celery
...
@@ -8,6 +8,7 @@ from celery import Celery
HOSTNAME
=
gethostname
()
HOSTNAME
=
gethostname
()
AMQP_URI
=
getenv
(
'AMQP_URI'
)
AMQP_URI
=
getenv
(
'AMQP_URI'
)
DNS_DB_DIR
=
getenv
(
'DNS_DB_DIR'
,
'/var/lib/circle/dnsdriver'
)
celery
=
Celery
(
'dnsdriver'
,
broker
=
AMQP_URI
)
celery
=
Celery
(
'dnsdriver'
,
broker
=
AMQP_URI
)
celery
.
conf
.
update
(
celery
.
conf
.
update
(
...
@@ -15,15 +16,15 @@ celery.conf.update(
...
@@ -15,15 +16,15 @@ celery.conf.update(
CELERY_TASK_RESULT_EXPIRES
=
300
,
CELERY_TASK_RESULT_EXPIRES
=
300
,
CELERY_QUEUES
=
(
CELERY_QUEUES
=
(
Queue
(
HOSTNAME
+
'.dns'
,
Exchange
(
Queue
(
HOSTNAME
+
'.dns'
,
Exchange
(
'dnsdriver'
,
type
=
'direct'
),
routing_key
=
'dnsdriver'
),
'dnsdriver'
,
type
=
'direct'
),
routing_key
=
'dnsdriver'
),
)
)
)
)
@celery.task
(
name
=
'firewall.reload_dns'
)
@celery.task
(
name
=
'firewall.reload_dns'
)
def
t
(
data
):
def
reload_dns
(
data
):
with
open
(
'/etc/sv/tinydns/root/data'
,
'w'
)
as
f
:
with
open
(
path
.
join
(
DNS_DB_DIR
,
'data'
)
,
'w'
)
as
f
:
f
.
write
(
'
\n
'
.
join
(
data
))
f
.
write
(
'
\n
'
.
join
(
data
))
process
=
subprocess
.
Popen
([
'make'
,
'-C'
,
'/etc/sv/tinydns/root'
],
process
=
subprocess
.
Popen
([
'make'
,
'-C'
,
DNS_DB_DIR
],
shell
=
False
,
stdin
=
subprocess
.
PIPE
)
shell
=
False
,
stdin
=
subprocess
.
PIPE
)
process
.
communicate
(
'
\n
'
.
join
(
data
)
+
'
\n
'
)
process
.
communicate
(
'
\n
'
.
join
(
data
)
+
'
\n
'
)
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