Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
P
physical
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
吴升宇
physical
Commits
5265e429
Commit
5265e429
authored
Feb 20, 2019
by
lixiaofang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add
parent
59e9675f
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
24 additions
and
9 deletions
+24
-9
views.py
injection/data_sync/views.py
+9
-0
__init__.py
physical/__init__.py
+1
-1
celery_task_router.py
physical/celery_task_router.py
+8
-8
settings.py
physical/settings.py
+6
-0
No files found.
injection/data_sync/views.py
View file @
5265e429
from
django.shortcuts
import
render
from
django.shortcuts
import
render
# Create your views here.
# Create your views here.
from
injection.data_sync
import
tasks
from
django.http
import
JsonResponse
def
index
(
request
,
*
args
,
**
kwargs
):
res
=
tasks
.
add
.
delay
(
1
,
3
)
#任务逻辑
return
JsonResponse
({
'status'
:
'successful'
,
'task_id'
:
res
.
task_id
})
physical/__init__.py
View file @
5265e429
...
@@ -4,4 +4,4 @@ import pymysql
...
@@ -4,4 +4,4 @@ import pymysql
from
_celery
import
app
as
celery_app
from
_celery
import
app
as
celery_app
pymysql
.
install_as_MySQLdb
()
pymysql
.
install_as_MySQLdb
()
#
__all__ = ('celery_app',)
__all__
=
(
'celery_app'
,)
physical/celery_task_router.py
View file @
5265e429
# coding=utf-8
# coding=utf-8
from
__future__
import
unicode_literals
,
print_function
,
absolute_import
from
__future__
import
unicode_literals
,
print_function
,
absolute_import
import
itertools
import
itertools
from
django.conf
import
settings
from
django.conf
import
settings
import
logging
import
logging
class
CeleryTaskRouter
(
object
):
class
CeleryTaskRouter
(
object
):
queue_task_map
=
{
queue_task_map
=
{
"tapir-alpha"
:[
"tapir-alpha"
:
[
'injection.data_sync.tasks.write_to_es'
,
'injection.data_sync.tasks.write_to_es'
,
]
]
}
}
...
@@ -30,4 +31,4 @@ class CeleryTaskRouter(object):
...
@@ -30,4 +31,4 @@ class CeleryTaskRouter(object):
logging
.
info
(
"duan add,task is:
%
s"
%
str
(
task
))
logging
.
info
(
"duan add,task is:
%
s"
%
str
(
task
))
queue_name_or_none
=
self
.
task_queue_map
.
get
(
task
)
queue_name_or_none
=
self
.
task_queue_map
.
get
(
task
)
return
queue_name_or_none
return
queue_name_or_none
\ No newline at end of file
physical/settings.py
View file @
5265e429
...
@@ -56,6 +56,12 @@ BROKER_URL = "redis://127.0.0.1:6379/8"
...
@@ -56,6 +56,12 @@ BROKER_URL = "redis://127.0.0.1:6379/8"
CELERY_BROKER_URL
=
"redis://127.0.0.1:6379/8"
CELERY_BROKER_URL
=
"redis://127.0.0.1:6379/8"
CELERY_TIMEZONE
=
'Asia/Shanghai'
CELERY_TIMEZONE
=
'Asia/Shanghai'
CELERY_ROUTES
=
[
'physical.celery_task_router.CeleryTaskRouter'
]
CELERY_ROUTES
=
[
'physical.celery_task_router.CeleryTaskRouter'
]
CELERY_RESULT_SERIALIZER
=
'json'
# 结果序列化方案
CELERY_RESULT_BACKEND
=
'redis://10.1.210.69:6379/0'
# BACKEND配置,这里使用redis
INSTALLED_APPS
=
(
INSTALLED_APPS
=
(
'django.contrib.admin'
,
'django.contrib.admin'
,
...
...
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