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
73d1c310
Commit
73d1c310
authored
Dec 10, 2018
by
段英荣
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
modify
parent
2c56499c
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
31 additions
and
1 deletion
+31
-1
tasks.py
injection/data_sync/tasks.py
+3
-0
__init__.py
physical/__init__.py
+3
-0
celery.py
physical/celery.py
+24
-0
settings.py
physical/settings.py
+1
-1
No files found.
injection/data_sync/tasks.py
View file @
73d1c310
...
@@ -6,12 +6,15 @@ from django.core import serializers
...
@@ -6,12 +6,15 @@ from django.core import serializers
from
trans2es.type_info
import
get_type_info_map
from
trans2es.type_info
import
get_type_info_map
from
rpc.all
import
get_rpc_remote_invoker
from
rpc.all
import
get_rpc_remote_invoker
from
libs.es
import
ESPerform
from
libs.es
import
ESPerform
import
logging
@shared_task
@shared_task
def
write_to_es
(
es_type
,
pk_list
,
configuration
,
use_batch_query_set
=
False
):
def
write_to_es
(
es_type
,
pk_list
,
configuration
,
use_batch_query_set
=
False
):
pk_list
=
list
(
frozenset
(
pk_list
))
pk_list
=
list
(
frozenset
(
pk_list
))
type_info_map
=
get_type_info_map
()
type_info_map
=
get_type_info_map
()
type_info
=
type_info_map
[
es_type
]
type_info
=
type_info_map
[
es_type
]
logging
.
info
(
"duan add,es_type:
%
s"
%
str
(
es_type
))
type_info
.
insert_table_by_pk_list
(
type_info
.
insert_table_by_pk_list
(
sub_index_name
=
es_type
,
sub_index_name
=
es_type
,
pk_list
=
pk_list
,
pk_list
=
pk_list
,
...
...
physical/__init__.py
View file @
73d1c310
import
pymysql
import
pymysql
from
.celery
import
app
as
celery_app
pymysql
.
install_as_MySQLdb
()
pymysql
.
install_as_MySQLdb
()
__all__
=
(
'celery_app'
,)
physical/celery.py
0 → 100644
View file @
73d1c310
from
__future__
import
absolute_import
,
unicode_literals
import
os
from
celery
import
Celery
from
django.conf
import
settings
# set the default Django settings module for the 'celery' program.
os
.
environ
.
setdefault
(
'DJANGO_SETTINGS_MODULE'
,
'physical.settings'
)
app
=
Celery
(
'physical'
)
# Using a string here means the worker doesn't have to serialize
# the configuration object to child processes.
# - namespace='CELERY' means all celery-related configuration keys
# should have a `CELERY_` prefix.
app
.
config_from_object
(
'django.conf:settings'
,
namespace
=
'CELERY'
)
# Load task modules from all registered Django app configs.
app
.
autodiscover_tasks
()
app
.
conf
.
broker_url
=
settings
.
CELERY_BROKER_URL
@app.task
(
bind
=
True
)
def
debug_task
(
self
):
print
(
'Request: {0!r}'
.
format
(
self
.
request
))
physical/settings.py
View file @
73d1c310
...
@@ -30,7 +30,7 @@ ALLOWED_HOSTS = []
...
@@ -30,7 +30,7 @@ ALLOWED_HOSTS = []
# Application definition
# Application definition
BROKER_URL
=
"redis://127.0.0.1:6379/0
"
CELERY_BROKER_URL
=
"redis://127.0.0.1:6379/2
"
CELERY_TIMEZONE
=
'Asia/Shanghai'
CELERY_TIMEZONE
=
'Asia/Shanghai'
CELERY_ROUTES
=
[
'physical.celery_task_router.CeleryTaskRouter'
]
CELERY_ROUTES
=
[
'physical.celery_task_router.CeleryTaskRouter'
]
...
...
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