parent
8b0fab87b5
commit
0df8cf68be
@ -0,0 +1,43 @@ |
||||
#!/usr/bin/env python |
||||
# -*- coding:utf-8 -*- |
||||
# project: 5月 |
||||
# author: NinEveN |
||||
# date: 2021/5/27 |
||||
|
||||
from celery import shared_task |
||||
from django.core.cache import cache |
||||
|
||||
from api.models import Apps |
||||
from api.utils.app.supersignutils import IosUtils, resign_by_app_id |
||||
|
||||
|
||||
@shared_task |
||||
def run_sign_task(format_udid_info, short): |
||||
app_info = Apps.objects.filter(short=short).first() |
||||
with cache.lock("%s_%s_%s" % ('task_sign', app_info.app_id, format_udid_info.get('udid')), timeout=60 * 10): |
||||
ios_obj = IosUtils(format_udid_info, app_info.user_id, app_info) |
||||
status, msg = ios_obj.sign() |
||||
if not status: |
||||
code = msg.get("code", -1) |
||||
if code == 0: |
||||
msg = "" |
||||
elif code == 1005: |
||||
msg = "签名余额不足" |
||||
elif code == 1002: |
||||
msg = "维护中" |
||||
elif code == 1003: |
||||
msg = "应用余额不足" |
||||
elif code in [1004, 1001, 1009]: |
||||
msg = msg.get('msg', '未知错误') |
||||
else: |
||||
msg = '系统内部错误' |
||||
else: |
||||
msg = "" |
||||
return msg |
||||
|
||||
|
||||
@shared_task |
||||
def run_resign_task(app_id, need_download_profile=True): |
||||
app_obj = Apps.objects.filter(app_id=app_id).first() |
||||
with cache.lock("%s_%s" % ('task_resign', app_id), timeout=60 * 60): |
||||
return resign_by_app_id(app_obj, need_download_profile) |
@ -0,0 +1,5 @@ |
||||
#!/usr/bin/env python |
||||
# -*- coding:utf-8 -*- |
||||
# project: 5月 |
||||
# author: NinEveN |
||||
# date: 2021/5/27 |
@ -0,0 +1,3 @@ |
||||
from .celery import app as celery_app |
||||
|
||||
__all__ = ('celery_app',) |
@ -0,0 +1,43 @@ |
||||
#!/usr/bin/env python |
||||
# -*- coding:utf-8 -*- |
||||
# project: 5月 |
||||
# author: NinEveN |
||||
# date: 2021/5/27 |
||||
|
||||
import os |
||||
from celery import Celery |
||||
|
||||
# set the default Django settings module for the 'celery' program. |
||||
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'fir_ser.settings') |
||||
|
||||
app = Celery('fir_ser') |
||||
|
||||
# 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 apps. |
||||
app.autodiscover_tasks() |
||||
|
||||
|
||||
@app.task(bind=True) |
||||
def debug_task(self): |
||||
print('Request: {0!r}'.format(self.request)) |
||||
|
||||
|
||||
''' |
||||
pip install django-celery-beat==1.1.0 |
||||
export PYTHONOPTIMIZE=1 |
||||
celery -A DevOps beat -l info -S django --logfile=./celery.beat.log |
||||
|
||||
celery multi start b1 -A DevOps beat -l info -S django |
||||
|
||||
export PYTHONOPTIMIZE=1 |
||||
celery -O OPTIMIZATION -A DevOps worker -l debug |
||||
|
||||
celery multi start w1 -O OPTIMIZATION -A DevOps worker -l info --logfile=./celery.worker.log |
||||
|
||||
celery -A DevOps flower --port=5566 |
||||
''' |
Loading…
Reference in new issue