优化代码展示

xsign
MMXX 3 years ago
parent cf14dcb0a5
commit eeba5b409a
  1. 77
      fir_client/src/components/user/FirSuperSignBase.vue
  2. 7
      fir_ser/api/management/commands/services/hands.py
  3. 2
      fir_ser/api/management/commands/services/services/base.py
  4. 1
      fir_ser/api/management/commands/services/utils.py
  5. 7
      fir_ser/api/tasks.py
  6. 9
      fir_ser/api/utils/ctasks.py
  7. 16
      fir_ser/fir_ser/settings.py
  8. 2
      fir_ser/readme.txt
  9. 2
      fir_ser/xsign/utils/iossignapi.py
  10. 4
      fir_ser/xsign/utils/supersignutils.py
  11. 3
      fir_ser/xsign/views/supersign.py

@ -139,7 +139,7 @@
<el-input v-model="editdeveloperinfo.certid" :disabled='isedit'/> <el-input v-model="editdeveloperinfo.certid" :disabled='isedit'/>
</el-form-item> </el-form-item>
<el-form-item label="备注" label-width="110px"> <el-form-item label="备注" label-width="110px">
<el-input v-model="editdeveloperinfo.description"/> <el-input v-model="editdeveloperinfo.description" :rows="3" type="textarea"/>
</el-form-item> </el-form-item>
<div style=""> <div style="">
<el-button v-if="isedit && editdeveloperinfo.certid" size="small" <el-button v-if="isedit && editdeveloperinfo.certid" size="small"
@ -164,7 +164,7 @@
<el-button v-if="isedit && editdeveloperinfo.status!==0" size="small" type="success" <el-button v-if="isedit && editdeveloperinfo.status!==0" size="small" type="success"
@click="activedeveloperFun(editdeveloperinfo,'checkauth')">账户激活检测 @click="activedeveloperFun(editdeveloperinfo,'checkauth')">账户激活检测
</el-button> </el-button>
<el-divider/> <el-divider v-if="isedit && editdeveloperinfo.certid"/>
<el-tooltip content="清理发布证书,如果发布证书过期时间大于3天,将不会删除开发者发布证书,发布证书只能同时创建两个,请谨慎操作"> <el-tooltip content="清理发布证书,如果发布证书过期时间大于3天,将不会删除开发者发布证书,发布证书只能同时创建两个,请谨慎操作">
<div> <div>
<el-button v-if="isedit && editdeveloperinfo.certid" <el-button v-if="isedit && editdeveloperinfo.certid"
@ -399,9 +399,9 @@
<el-table-column <el-table-column
align="center" align="center"
fixed fixed
label="开发者ID issuer_id" label="开发者 ID issuer_id"
prop="issuer_id" prop="issuer_id"
width="160"> width="180">
<template slot-scope="scope"> <template slot-scope="scope">
<el-popover placement="top" trigger="hover"> <el-popover placement="top" trigger="hover">
<el-tooltip content="点击复制到剪贴板"> <el-tooltip content="点击复制到剪贴板">
@ -428,21 +428,6 @@
</template> </template>
</el-table-column> </el-table-column>
<el-table-column
align="center"
label="是否激活"
prop="status"
width="105">
<template slot-scope="scope">
<el-tooltip v-if="scope.row.status!==0" content="点击禁用">
<el-button size="small" type="success" @click="disabledeveloperFun(scope.row,'disable')">已激活</el-button>
</el-tooltip>
<el-button v-else size="small" type="danger"
@click="activedeveloperFun(scope.row,'checkauth')">点击激活
</el-button>
</template>
</el-table-column>
<el-table-column <el-table-column
align="center" align="center"
label="账户状态" label="账户状态"
@ -452,20 +437,38 @@
<template slot-scope="scope"> <template slot-scope="scope">
<el-popover placement="top" trigger="hover"> <el-popover placement="top" trigger="hover">
<p v-if="!scope.row.certid && scope.row.status!==0"> <p v-if="!scope.row.certid && scope.row.status!==0">
开发证书不可用请在编辑中导入或手动创建发布证书</p> 开发证书不可用请在
<p v-if="!scope.row.certid && scope.row.status=== 0">请先激活开发者账户</p> <el-link :underline="false" type="primary" @click="handleEditDeveloper(scope.row)">编辑</el-link>
中导入或手动创建发布证书
</p>
<p v-if="scope.row.status=== 0">
<el-link :underline="false" type="primary" @click="activedeveloperFun(scope.row,'checkauth')">点击激活
</el-link>
开发者账户
</p>
<p v-if="scope.row.certid && scope.row.status!==0">{{ format_status(scope.row.status) }}</p> <p v-if="scope.row.certid && scope.row.status!==0">{{ format_status(scope.row.status) }}</p>
<div slot="reference" class="name-wrapper"> <div slot="reference" class="name-wrapper">
<div v-if="scope.row.certid"> <div v-if="scope.row.status=== 0">
<el-button v-if="scope.row.status === 1" size="small" type="success"> <el-button size="small" type="danger"
{{ format_status(scope.row.status) }} @click="activedeveloperFun(scope.row,'checkauth')">点击激活
</el-button>
<el-button v-else size="small" type="warning" @click="activedeveloperFun(scope.row,'checkauth')">
{{ format_status(scope.row.status) }}
</el-button> </el-button>
</div> </div>
<div v-else-if="scope.row.status === 1">
<el-button v-else size="small" type="danger">不可用</el-button> <el-tooltip v-if="scope.row.status!==0" content="点击禁用">
<el-button v-if="scope.row.certid" size="small" type="success"
@click="disabledeveloperFun(scope.row,'disable')">
{{ format_status(scope.row.status) }}
</el-button>
<el-button v-else size="small" type="warning" @click="disabledeveloperFun(scope.row,'disable')">
不可用
</el-button>
</el-tooltip>
</div>
<el-button v-else size="small" type="warning" @click="activedeveloperFun(scope.row,'checkauth')">
{{ format_status(scope.row.status) }}
</el-button>
</div> </div>
</el-popover> </el-popover>
@ -559,19 +562,21 @@
<el-tag v-else size="medium" type="info"></el-tag> <el-tag v-else size="medium" type="info"></el-tag>
</template> </template>
</el-table-column> </el-table-column>
<el-table-column
:formatter="formatter"
align="center"
label="证书到期时间"
prop="cert_expire_time"
width="160">
</el-table-column>
<el-table-column <el-table-column
align="center" align="center"
label="备注" label="备注"
min-width="160"
prop="description" prop="description"
> >
</el-table-column> </el-table-column>
<el-table-column
:formatter="formatter"
align="center"
label="证书到期时间"
prop="cert_expire_time"
width="100">
</el-table-column>
<el-table-column <el-table-column
align="center" align="center"
fixed="right" fixed="right"

@ -7,8 +7,10 @@ import time
import psutil import psutil
from django.conf import settings from django.conf import settings
from api.tasks import start_api_sever_do_clean
from config import BASECONF from config import BASECONF
from config import BASE_DIR from config import BASE_DIR
from xsign.utils.iproxy import clean_ip_proxy_infos
try: try:
__version__ = BASECONF.VERSION __version__ = BASECONF.VERSION
@ -69,6 +71,11 @@ def prepare():
perform_db_migrate() perform_db_migrate()
def clean_cache():
start_api_sever_do_clean()
clean_ip_proxy_infos()
def get_sys_thread_num(): def get_sys_thread_num():
return psutil.cpu_count(False) if psutil.cpu_count(False) else 2 return psutil.cpu_count(False) if psutil.cpu_count(False) else 2

@ -141,6 +141,8 @@ class BaseService(object):
uid = get_user_id(self.uid) uid = get_user_id(self.uid)
gid = get_user_id(self.gid) gid = get_user_id(self.gid)
u_gid = uid if uid else gid u_gid = uid if uid else gid
if u_gid is None:
u_gid = os.getuid()
if u_gid is not None: if u_gid is not None:
for (dir_path, dir_names, filenames) in os.walk(LOG_DIR): for (dir_path, dir_names, filenames) in os.walk(LOG_DIR):
for filename in filenames + dir_names: for filename in filenames + dir_names:

@ -39,6 +39,7 @@ class ServicesUtil(object):
def start(self): def start(self):
if 'uwsgi' in [service.name for service in self._services]: if 'uwsgi' in [service.name for service in self._services]:
prepare() prepare()
clean_cache()
for service in self._services: for service in self._services:
service: BaseService service: BaseService

@ -8,7 +8,7 @@ import logging
from captcha.models import CaptchaStore from captcha.models import CaptchaStore
from api.utils.ctasks import sync_download_times, auto_clean_upload_tmp_file from api.utils.ctasks import sync_download_times, auto_clean_upload_tmp_file, auto_clean_remote_client_log
from api.views.login import get_login_type from api.views.login import get_login_type
from common.core.sysconfig import Config, invalid_config_cache from common.core.sysconfig import Config, invalid_config_cache
from common.libs.geetest.geetest_utils import check_bypass_status from common.libs.geetest.geetest_utils import check_bypass_status
@ -64,3 +64,8 @@ def auto_delete_tmp_file_job():
def sync_wx_access_token_job(): def sync_wx_access_token_job():
if get_login_type().get('third', '').get('wxp'): if get_login_type().get('third', '').get('wxp'):
sync_wx_access_token() sync_wx_access_token()
@app.task
def auto_clean_remote_client_job():
auto_clean_remote_client_log()

@ -3,13 +3,13 @@
# project: 4月 # project: 4月
# author: liuyu # author: liuyu
# date: 2020/4/7 # date: 2020/4/7
import datetime
import logging import logging
import time import time
from django.core.cache import cache from django.core.cache import cache
from api.models import Apps, UserInfo from api.models import Apps, UserInfo, RemoteClientInfo
from common.utils.storage import Storage from common.utils.storage import Storage
from fir_ser.settings import CACHE_KEY_TEMPLATE from fir_ser.settings import CACHE_KEY_TEMPLATE
@ -45,3 +45,8 @@ def auto_clean_upload_tmp_file():
cache.delete(upload_tem_file_key) cache.delete(upload_tem_file_key)
logger.info(f"auto_clean_upload_tmp_file upload_tem_file_key :{upload_tem_file_key}") logger.info(f"auto_clean_upload_tmp_file upload_tem_file_key :{upload_tem_file_key}")
def auto_clean_remote_client_log(clean_day=30):
clean_time = datetime.datetime.now() - datetime.timedelta(days=clean_day)
return RemoteClientInfo.objects.filter(created_time__lt=clean_time).delete()

@ -459,18 +459,12 @@ CELERY_BEAT_SCHEDULE = {
'schedule': SYNC_CACHE_TO_DATABASE.get("auto_clean_captcha_store_times"), 'schedule': SYNC_CACHE_TO_DATABASE.get("auto_clean_captcha_store_times"),
'args': () 'args': ()
}, },
'auto_check_ios_developer_active_job': { 'auto_clean_remote_client_job': {
'task': 'xsign.tasks.auto_check_ios_developer_active_job', 'task': 'api.tasks.auto_clean_remote_client_job',
# 'schedule': SYNC_CACHE_TO_DATABASE.get("auto_check_ios_developer_active_times"), # 'schedule': SYNC_CACHE_TO_DATABASE.get("auto_check_ios_developer_active_times"),
'schedule': crontab(hour=1, minute=1), 'schedule': crontab(hour=1, minute=1),
'args': () 'args': ()
}, },
# 'start_api_sever_do_clean': {
# 'task': 'api.tasks.start_api_sever_do_clean',
# 'schedule': 6,
# 'args': (),
# 'one_off': True
# },
'sync_wx_access_token_job': { 'sync_wx_access_token_job': {
'task': 'api.tasks.sync_wx_access_token_job', 'task': 'api.tasks.sync_wx_access_token_job',
'schedule': SYNC_CACHE_TO_DATABASE.get("wx_get_access_token_times"), 'schedule': SYNC_CACHE_TO_DATABASE.get("wx_get_access_token_times"),
@ -481,6 +475,12 @@ CELERY_BEAT_SCHEDULE = {
'schedule': SYNC_CACHE_TO_DATABASE.get("best_proxy_ips_times"), 'schedule': SYNC_CACHE_TO_DATABASE.get("best_proxy_ips_times"),
'args': (), 'args': (),
}, },
'auto_check_ios_developer_active_job': {
'task': 'xsign.tasks.auto_check_ios_developer_active_job',
# 'schedule': SYNC_CACHE_TO_DATABASE.get("auto_check_ios_developer_active_times"),
'schedule': crontab(hour=1, minute=1),
'args': ()
},
} }
# listen port # listen port

@ -12,6 +12,8 @@ celery multi start 4 -A fir_ser -l INFO -c4 --pidfile=/var/run/celery/%n.pid --
启动beat 启动beat
nohup celery -A fir_ser beat --uid=1000 --pidfile=logs/beat.pid --scheduler django -l INFO --logfile=logs/beat.log & nohup celery -A fir_ser beat --uid=1000 --pidfile=logs/beat.pid --scheduler django -l INFO --logfile=logs/beat.log &
# 启动uwsgi 建议修改 /proc/sys/net/core/somaxconn 为512
# 或者在 /etc/sysctl.conf 底部加入 net.core.somaxconn = 512 ,然后 sysctl -p
#开发测试 #开发测试
celery -A fir_ser worker --uid=1000 --beat --scheduler django --loglevel=debug celery -A fir_ser worker --uid=1000 --beat --scheduler django --loglevel=debug

@ -254,7 +254,7 @@ class AppDeveloperApiV2(object):
attr = object.__getattribute__(self, name) attr = object.__getattribute__(self, name)
if hasattr(attr, '__call__'): if hasattr(attr, '__call__'):
def func(*args, **kwargs): def func(*args, **kwargs):
if attr.__name__ in ['active', 'get_device']: if attr.__name__ in ['active', 'get_device', '__result_format']:
return attr(*args, **kwargs) return attr(*args, **kwargs)
else: else:
if AppIOSDeveloperInfo.objects.filter(pk=self.developer_pk, if AppIOSDeveloperInfo.objects.filter(pk=self.developer_pk,

@ -1071,6 +1071,10 @@ class IosUtils(object):
def get_device_from_developer(developer_obj): def get_device_from_developer(developer_obj):
app_api_obj = get_api_obj(developer_obj) app_api_obj = get_api_obj(developer_obj)
status, result = app_api_obj.get_device() status, result = app_api_obj.get_device()
# 获取设备列表的时候,有时候会发生灵异事件,尝试多次获取 【也可能是未知bug导致】
if status and isinstance(result, list) and len(result) == 0:
time.sleep(2)
status, result = app_api_obj.get_device()
if status and developer_obj.issuer_id: if status and developer_obj.issuer_id:
udid_developer_obj_list = UDIDsyncDeveloper.objects.filter(developerid=developer_obj).values_list('udid') udid_developer_obj_list = UDIDsyncDeveloper.objects.filter(developerid=developer_obj).values_list('udid')

@ -129,8 +129,7 @@ class DeveloperView(APIView):
if act == "checkauth": if act == "checkauth":
status, result = IosUtils.active_developer(developer_obj) status, result = IosUtils.active_developer(developer_obj)
if status: if status:
if not developer_obj.certid: IosUtils.get_device_from_developer(developer_obj)
IosUtils.get_device_from_developer(developer_obj)
return Response(res.dict) return Response(res.dict)
else: else:
res.code = 1008 res.code = 1008

Loading…
Cancel
Save