Przeglądaj źródła

修改正式服配置

locky 2 tygodni temu
rodzic
commit
d63982093f

+ 17 - 16
AnsjerPush/cn_config/cn_formal_settings.py

@@ -22,7 +22,7 @@ MIDDLEWARE = [
     'django.contrib.sessions.middleware.SessionMiddleware',
     'corsheaders.middleware.CorsMiddleware',
     'django.middleware.common.CommonMiddleware',
-    'MiddleWare.requestRecord.RequestRecordMiddleware',  # 记录请求信息
+    # 'MiddleWare.requestRecord.RequestRecordMiddleware',  # 记录请求信息
     # 'django.middleware.csrf.CsrfViewMiddleware',
     'django.contrib.auth.middleware.AuthenticationMiddleware',
     'django.contrib.messages.middleware.MessageMiddleware',
@@ -187,10 +187,10 @@ LOGGING = {
         },
         'default': {
             'level': 'ERROR',
-            'class': 'logging.handlers.RotatingFileHandler',
+            'class': 'concurrent_log_handler.ConcurrentRotatingFileHandler',
             'filename': BASE_DIR + '/static/log/error/error.log',
             'maxBytes': 1024 * 1024 * 5,  # 5 MB
-            'backupCount': 5,
+            'backupCount': 3,
             'formatter': 'error_format',
         },
         'console': {
@@ -198,47 +198,48 @@ LOGGING = {
             'class': 'logging.StreamHandler',
             'formatter': 'error_format'
         },
+        # 总计info、time、v1_push日志给57GB空间
         'info': {
             'level': 'INFO',
-            'class': 'logging.handlers.RotatingFileHandler',
+            'class': 'concurrent_log_handler.ConcurrentRotatingFileHandler',
             'filename': BASE_DIR + '/static/log/info/info.log',
-            'backupCount': 10,
-            'maxBytes': 1024 * 1024 * 2 * 1024,  # 2G
+            'backupCount': 3,
+            'maxBytes': 1024 * 1024 * 2 * 1024,  # 一天以内2GB 保存5天共10GB
             'formatter': 'standard',
             'encoding': 'utf-8',
         },
         'time': {
             'level': 'INFO',
-            'class': 'logging.handlers.RotatingFileHandler',
+            'class': 'concurrent_log_handler.ConcurrentRotatingFileHandler',
             'filename': BASE_DIR + '/static/log/time/info.log',
-            'backupCount': 10,
-            'maxBytes': 1024 * 1024 * 2 * 1024,  # 2G
+            'backupCount': 7,
+            'maxBytes': 1024 * 1024 * 5 * 1024,  # 一天9GB 保存5天 共45GB
             'formatter': 'standard',
             'encoding': 'utf-8',
         },
         'v1_push': {
             'level': 'INFO',
-            'class': 'logging.handlers.RotatingFileHandler',
+            'class': 'concurrent_log_handler.ConcurrentRotatingFileHandler',
             'filename': BASE_DIR + '/static/log/v1log/info.log',
-            'backupCount': 10,
-            'maxBytes': 1024 * 1024 * 2 * 1024,  # 2G
+            'backupCount': 1,
+            'maxBytes': 1024 * 1024 * 1 * 1024,  # 一天0.05GB 保存40天 共2GB
             'formatter': 'standard',
             'encoding': 'utf-8',
         },
         'customized_push': {
             'level': 'INFO',
-            'class': 'logging.handlers.RotatingFileHandler',
+            'class': 'concurrent_log_handler.ConcurrentRotatingFileHandler',
             'filename': BASE_DIR + '/static/log/customized_push/info.log',
-            'backupCount': 10,
+            'backupCount': 3,
             'maxBytes': 1024 * 1024 * 2 * 100,  # 100M
             'formatter': 'standard',
             'encoding': 'utf-8',
         },
         'error_info': {
             'level': 'INFO',
-            'class': 'logging.handlers.RotatingFileHandler',
+            'class': 'concurrent_log_handler.ConcurrentRotatingFileHandler',
             'filename': BASE_DIR + '/static/log/error_info/info.log',
-            'backupCount': 10,
+            'backupCount': 3,
             'maxBytes': 1024 * 1024 * 2 * 100,  # 100M
             'formatter': 'standard',
             'encoding': 'utf-8',

+ 45 - 35
AnsjerPush/eur_config/eur_formal_settings.py

@@ -1,8 +1,20 @@
 import os
+from AnsjerPush.config import BASE_DIR
+import environ
+
+env = environ.Env(
+    DEBUG=(bool, False)
+)
+# 读取 .env 文件
+environ.Env.read_env(os.path.join(BASE_DIR, '.env'))
+
+ACCESS_KEY_ID = env('ACCESS_KEY_ID', default='')
+SECRET_ACCESS_KEY = env('SECRET_ACCESS_KEY', default='')
+AWS_ACCESS_KEY_ID = env.list('AWS_ACCESS_KEY_ID', default=[])
+AWS_SECRET_ACCESS_KEY = env.list('AWS_SECRET_ACCESS_KEY', default=[])
 
-BASE_DIR = os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
 SECRET_KEY = '$2hf5g$a%_^kk0-l25l$!o5)yc=dvtnfpc8(+$rh4fq4twa_xx'
-DEBUG = False
+DEBUG = True
 ALLOWED_HOSTS = ["*"]
 
 INSTALLED_APPS = [
@@ -22,7 +34,7 @@ MIDDLEWARE = [
     'django.contrib.sessions.middleware.SessionMiddleware',
     'corsheaders.middleware.CorsMiddleware',
     'django.middleware.common.CommonMiddleware',
-    'MiddleWare.requestRecord.RequestRecordMiddleware',  # 记录请求信息
+    # 'MiddleWare.requestRecord.RequestRecordMiddleware',  # 记录请求信息
     # 'django.middleware.csrf.CsrfViewMiddleware',
     'django.contrib.auth.middleware.AuthenticationMiddleware',
     'django.contrib.messages.middleware.MessageMiddleware',
@@ -50,19 +62,17 @@ TEMPLATES = [
 
 WSGI_APPLICATION = 'AnsjerPush.wsgi.application'
 
+# 业务数据库
+DATABASE_DATA = env('DATABASE_DATA')
+SERVER_HOST = env('SERVER_HOST')
+DATABASES_USER = env('DATABASES_USER')
+DATABASES_PASS = env('DATABASES_PASS')
 
-# Database
-# https://docs.djangoproject.com/en/2.1/ref/settings/#databases
-# formal
-DATABASE_DATA = 'Ansjer81'
-SERVER_HOST = 'server-eur.chi0brrjyz8l.eu-west-1.rds.amazonaws.com'
-DATABASES_USER = 'azrds'
-DATABASES_PASS = '47vo87fikT19cekVoSq1'
-
-DATABASE_DATA2 = 'Ansjer81'
-SERVER_HOST2 = 'push-eur.chi0brrjyz8l.eu-west-1.rds.amazonaws.com'
-DATABASES_USER2 = 'azrds'
-DATABASES_PASS2 = '5T0LVKsXwHFkYNTTa5UG'
+# 推送数据库
+DATABASE_DATA2 = env('DATABASE_DATA2')
+SERVER_HOST2 = env('SERVER_HOST2')
+DATABASES_USER2 = env('DATABASES_USER2')
+DATABASES_PASS2 = env('DATABASES_PASS2')
 
 DATABASES = {
     'default': {
@@ -181,10 +191,10 @@ LOGGING = {
         },
         'default': {
             'level': 'ERROR',
-            'class': 'logging.handlers.RotatingFileHandler',
+            'class': 'concurrent_log_handler.ConcurrentRotatingFileHandler',
             'filename': BASE_DIR + '/static/log/error/error.log',
             'maxBytes': 1024 * 1024 * 5,  # 5 MB
-            'backupCount': 5,
+            'backupCount': 3,
             'formatter': 'error_format',
         },
         'console': {
@@ -194,48 +204,48 @@ LOGGING = {
         },
         'info': {
             'level': 'INFO',
-            'class': 'logging.handlers.RotatingFileHandler',
+            'class': 'concurrent_log_handler.ConcurrentRotatingFileHandler',
             'filename': BASE_DIR + '/static/log/info/info.log',
-            'backupCount': 10,
-            'maxBytes': 1024 * 1024 * 2 * 1024,  # 2G
+            'backupCount': 3,
+            'maxBytes': 1024 * 1024 * 10 * 1024,  # 10G
             'formatter': 'standard',
-            'encoding': 'utf-8',
+            'encoding': 'utf-8'
         },
         'time': {
             'level': 'INFO',
-            'class': 'logging.handlers.RotatingFileHandler',
+            'class': 'concurrent_log_handler.ConcurrentRotatingFileHandler',
             'filename': BASE_DIR + '/static/log/time/info.log',
-            'backupCount': 10,
-            'maxBytes': 1024 * 1024 * 2 * 1024,  # 2G
+            'backupCount': 3,
+            'maxBytes': 1024 * 1024 * 10 * 1024,  # 10G
             'formatter': 'standard',
-            'encoding': 'utf-8',
+            'encoding': 'utf-8'
         },
         'v1_push': {
             'level': 'INFO',
-            'class': 'logging.handlers.RotatingFileHandler',
+            'class': 'concurrent_log_handler.ConcurrentRotatingFileHandler',
             'filename': BASE_DIR + '/static/log/v1log/info.log',
-            'backupCount': 10,
-            'maxBytes': 1024 * 1024 * 2 * 1024,  # 2G
+            'backupCount': 3,
+            'maxBytes': 1024 * 1024 * 10 * 1024,  # 10G
             'formatter': 'standard',
-            'encoding': 'utf-8',
+            'encoding': 'utf-8'
         },
         'customized_push': {
             'level': 'INFO',
-            'class': 'logging.handlers.RotatingFileHandler',
+            'class': 'concurrent_log_handler.ConcurrentRotatingFileHandler',
             'filename': BASE_DIR + '/static/log/customized_push/info.log',
-            'backupCount': 10,
+            'backupCount': 3,
             'maxBytes': 1024 * 1024 * 2 * 100,  # 100M
             'formatter': 'standard',
-            'encoding': 'utf-8',
+            'encoding': 'utf-8'
         },
         'error_info': {
             'level': 'INFO',
-            'class': 'logging.handlers.RotatingFileHandler',
+            'class': 'concurrent_log_handler.ConcurrentRotatingFileHandler',
             'filename': BASE_DIR + '/static/log/error_info/info.log',
-            'backupCount': 10,
+            'backupCount': 3,
             'maxBytes': 1024 * 1024 * 2 * 100,  # 100M
             'formatter': 'standard',
-            'encoding': 'utf-8',
+            'encoding': 'utf-8'
         },
     },
     'loggers': {

+ 20 - 20
AnsjerPush/us_config/formal_settings.py

@@ -188,10 +188,10 @@ LOGGING = {
         },
         'default': {
             'level': 'ERROR',
-            'class': 'logging.handlers.RotatingFileHandler',
+            'class': 'concurrent_log_handler.ConcurrentRotatingFileHandler',
             'filename': BASE_DIR + '/static/log/error/error.log',
             'maxBytes': 1024 * 1024 * 5,  # 5 MB
-            'backupCount': 5,
+            'backupCount': 3,
             'formatter': 'error_format',
         },
         'console': {
@@ -201,48 +201,48 @@ LOGGING = {
         },
         'info': {
             'level': 'INFO',
-            'class': 'logging.handlers.RotatingFileHandler',
+            'class': 'concurrent_log_handler.ConcurrentRotatingFileHandler',
             'filename': BASE_DIR + '/static/log/info/info.log',
-            'backupCount': 10,
-            'maxBytes': 1024 * 1024 * 2 * 1024,  # 2G
+            'backupCount': 3,
+            'maxBytes': 1024 * 1024 * 3 * 1024,  # 3G
             'formatter': 'standard',
-            'encoding': 'utf-8',
+            'encoding': 'utf-8'
         },
         'time': {
             'level': 'INFO',
-            'class': 'logging.handlers.RotatingFileHandler',
+            'class': 'concurrent_log_handler.ConcurrentRotatingFileHandler',
             'filename': BASE_DIR + '/static/log/time/info.log',
-            'backupCount': 10,
-            'maxBytes': 1024 * 1024 * 2 * 1024,  # 2G
+            'backupCount': 3,
+            'maxBytes': 1024 * 1024 * 7 * 1024,  # 7G
             'formatter': 'standard',
-            'encoding': 'utf-8',
+            'encoding': 'utf-8'
         },
         'v1_push': {
             'level': 'INFO',
-            'class': 'logging.handlers.RotatingFileHandler',
+            'class': 'concurrent_log_handler.ConcurrentRotatingFileHandler',
             'filename': BASE_DIR + '/static/log/v1log/info.log',
-            'backupCount': 10,
-            'maxBytes': 1024 * 1024 * 2 * 1024,  # 2G
+            'backupCount': 3,
+            'maxBytes': 1024 * 1024 * 8 * 1024,  # 8G
             'formatter': 'standard',
-            'encoding': 'utf-8',
+            'encoding': 'utf-8'
         },
         'customized_push': {
             'level': 'INFO',
-            'class': 'logging.handlers.RotatingFileHandler',
+            'class': 'concurrent_log_handler.ConcurrentRotatingFileHandler',
             'filename': BASE_DIR + '/static/log/customized_push/info.log',
-            'backupCount': 10,
+            'backupCount': 3,
             'maxBytes': 1024 * 1024 * 2 * 100,  # 100M
             'formatter': 'standard',
-            'encoding': 'utf-8',
+            'encoding': 'utf-8'
         },
         'error_info': {
             'level': 'INFO',
-            'class': 'logging.handlers.RotatingFileHandler',
+            'class': 'concurrent_log_handler.ConcurrentRotatingFileHandler',
             'filename': BASE_DIR + '/static/log/error_info/info.log',
-            'backupCount': 10,
+            'backupCount': 3,
             'maxBytes': 1024 * 1024 * 2 * 100,  # 100M
             'formatter': 'standard',
-            'encoding': 'utf-8',
+            'encoding': 'utf-8'
         },
     },
     'loggers': {

+ 5 - 12
Service/PushService.py

@@ -10,26 +10,19 @@ import json
 import logging
 import os
 import time
-
-import apns2
-import firebase_admin
 import jpush
 import requests
+import jwt
+import httpx
+
 from firebase_admin import messaging
 from pyfcm import FCMNotification
 
-from AnsjerPush.config import APP_BUNDLE_DICT, APNS_MODE, BASE_DIR, APNS_CONFIG, FCM_CONFIG, JPUSH_CONFIG, XMPUSH_CONFIG \
-    , VIVOPUSH_CONFIG, OPPOPUSH_CONFIG, MEIZUPUSH_CONFIG, CONFIG_INFO, HONORPUSH_CONFIG, DATA_PUSH_EVENT_TYPE_LIST, \
+from AnsjerPush.config import APP_BUNDLE_DICT, BASE_DIR, APNS_CONFIG, FCM_CONFIG, JPUSH_CONFIG, XMPUSH_CONFIG, \
+    VIVOPUSH_CONFIG, OPPOPUSH_CONFIG, MEIZUPUSH_CONFIG, CONFIG_INFO, HONORPUSH_CONFIG, DATA_PUSH_EVENT_TYPE_LIST, \
     CONFIG_TEST
-from AnsjerPush.packages import apns2
-import jwt
-import httpx
-
 from Model.models import UidPushModel
-from Object.RedisObject import RedisObject
-from Object.S3Email import S3Email
 from Object.enums.ConstantEnum import ConstantEnum
-from Object.enums.EventTypeEnum import EventTypeEnumObj
 from Service.CommonService import CommonService
 from Service.VivoPushService.push_admin.APIMessage import PushMessage
 from Service.VivoPushService.push_admin.APISender import APISender

+ 3 - 3
requirements.txt

@@ -38,11 +38,11 @@ greenlet==3.0.3
 grpcio==1.63.0
 grpcio-status==1.62.2
 gunicorn==22.0.0
-h2==4.3.0
-hpack==3.0.0
+h2==4.0.0
+hpack==4.0.0
 httplib2==0.22.0
 hyper==0.7.0
-hyperframe==3.2.0
+hyperframe==6.0.1
 httpx==0.28.1
 idna==3.7
 image==1.5.33