Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
J
jumpserver
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
ops
jumpserver
Commits
26352174
Commit
26352174
authored
Nov 11, 2016
by
ibuler
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Update celery
parent
c6fc3dfe
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
55 additions
and
29 deletions
+55
-29
tasks.py
apps/audits/tasks.py
+2
-2
celerybeat-schedule.db
apps/celerybeat-schedule.db
+0
-0
celerybeat.pid
apps/celerybeat.pid
+1
-0
__init__.py
apps/common/__init__.py
+1
-1
celery.py
apps/common/celery.py
+20
-21
tasks.py
apps/common/tasks.py
+31
-5
No files found.
apps/audits/tasks.py
View file @
26352174
...
...
@@ -8,4 +8,5 @@ from .utils import write_login_log
@shared_task
def
write_login_log_async
(
*
args
,
**
kwargs
):
write_login_log
(
*
args
,
**
kwargs
)
\ No newline at end of file
write_login_log
(
*
args
,
**
kwargs
)
apps/celerybeat-schedule.db
0 → 100644
View file @
26352174
apps/celerybeat.pid
0 → 100644
View file @
26352174
64256
apps/common/__init__.py
View file @
26352174
...
...
@@ -2,5 +2,5 @@ from __future__ import absolute_import
# This will make sure the app is always imported when
# Django starts so that shared_task will use this app.
from
.celery
import
app
as
celery_app
#
from .celery import app as celery_app
apps/common/celery.py
View file @
26352174
# ~*~ coding: utf-8 ~*~
from
__future__
import
absolute_import
,
unicode_literals
import
os
from
celery
import
Celery
# set the default Django settings module for the 'celery' program.
os
.
environ
.
setdefault
(
'DJANGO_SETTINGS_MODULE'
,
'jumpserver.settings'
)
from
django.conf
import
settings
app
=
Celery
(
'jumpserver'
)
# Using a string here means the worker will not have to
# pickle the object when using Windows.
app
.
config_from_object
(
'django.conf:settings'
)
app
.
autodiscover_tasks
(
lambda
:
[
app_config
.
split
(
'.'
)[
0
]
for
app_config
in
settings
.
INSTALLED_APPS
])
# # ~*~ coding: utf-8 ~*~
#
# from __future__ import absolute_import, unicode_literals
# import os
#
# from celery import Celery
#
# # set the default Django settings module for the 'celery' program.
# os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'jumpserver.settings')
#
# from django.conf import settings
#
# app = Celery('jumpserver')
#
# # Using a string here means the worker will not have to
# # pickle the object when using Windows.
# app.config_from_object('django.conf:settings')
#
# app.autodiscover_tasks(lambda: [app_config.split('.')[0] for app_config in settings.INSTALLED_APPS])
#
apps/common/tasks.py
View file @
26352174
from
__future__
import
absolute_import
import
os
from
celery
import
shared_task
from
celery.schedules
import
crontab
from
django.core.mail
import
send_mail
# from django.conf import settings
# from common import celery_app
from
celery
import
Celery
# set the default Django settings module for the 'celery' program.
os
.
environ
.
setdefault
(
'DJANGO_SETTINGS_MODULE'
,
'jumpserver.settings'
)
from
django.conf
import
settings
app
=
Celery
(
'jumpserver'
)
@shared_task
(
name
=
'send_mail_async'
)
# Using a string here means the worker will not have to
# pickle the object when using Windows.
app
.
config_from_object
(
'django.conf:settings'
)
app
.
autodiscover_tasks
(
lambda
:
[
app_config
.
split
(
'.'
)[
0
]
for
app_config
in
settings
.
INSTALLED_APPS
])
@app.task
def
send_mail_async
(
*
args
,
**
kwargs
):
""" Using celery to send email async
...
...
@@ -28,7 +46,15 @@ def send_mail_async(*args, **kwargs):
send_mail
(
*
args
,
**
kwargs
)
# def send_mail_async(subject, message, from_mail, recipient_list, fail_silently=False, html_message=None):
# if settings.CONFIG.MAIL_SUBJECT_PREFIX:
# subject += settings.CONFIG.MAIL_SUBJECT_PREFIX
# send_mail(subject, message, from_mail, recipient_list, fail_silently=fail_silently, html_message=html_message)
# @celery_app.task
# def test(arg):
# print(arg)
# celery_app.conf.beat_schedule = {
# 'add-every-30-seconds': {
# 'task': 'common.test',
# 'schedule': crontab(minute='*/1'),
# 'args': ('nihao',)
# }
# }
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