gunicorn
This commit is contained in:
@@ -194,3 +194,17 @@ UNFOLD = {
|
|||||||
|
|
||||||
# 禁用自动补齐斜杠,防止破坏微信支付的 POST 回调
|
# 禁用自动补齐斜杠,防止破坏微信支付的 POST 回调
|
||||||
APPEND_SLASH = False
|
APPEND_SLASH = False
|
||||||
|
|
||||||
|
LOGGING = {
|
||||||
|
'version': 1,
|
||||||
|
'disable_existing_loggers': False,
|
||||||
|
'handlers': {
|
||||||
|
'console': {
|
||||||
|
'class': 'logging.StreamHandler',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
'root': {
|
||||||
|
'handlers': ['console'],
|
||||||
|
'level': 'INFO',
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|||||||
@@ -71,11 +71,19 @@ def get_wechat_pay_client():
|
|||||||
if private_key:
|
if private_key:
|
||||||
# 统一处理私钥格式
|
# 统一处理私钥格式
|
||||||
private_key = private_key.strip()
|
private_key = private_key.strip()
|
||||||
if 'BEGIN PRIVATE KEY' not in private_key:
|
|
||||||
|
# 移除可能存在的首尾空白字符
|
||||||
|
if 'BEGIN PRIVATE KEY' in private_key:
|
||||||
|
# 如果已经包含 PEM 头,尝试清理并重新格式化
|
||||||
|
lines = private_key.split('\n')
|
||||||
|
clean_lines = [line.strip() for line in lines if line.strip()]
|
||||||
|
private_key = '\n'.join(clean_lines)
|
||||||
|
else:
|
||||||
|
# 如果没有头尾,说明是纯 base64 内容,尝试添加
|
||||||
private_key = f"-----BEGIN PRIVATE KEY-----\n{private_key}\n-----END PRIVATE KEY-----"
|
private_key = f"-----BEGIN PRIVATE KEY-----\n{private_key}\n-----END PRIVATE KEY-----"
|
||||||
|
|
||||||
if not private_key:
|
if not private_key:
|
||||||
return None, "缺少商户私钥"
|
return None, "缺少商户私钥 (未找到文件且数据库配置为空)"
|
||||||
|
|
||||||
# 确保回调地址以斜杠结尾
|
# 确保回调地址以斜杠结尾
|
||||||
if not notify_url.endswith('/'):
|
if not notify_url.endswith('/'):
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
services:
|
services:
|
||||||
backend:
|
backend:
|
||||||
build: ./backend
|
build: ./backend
|
||||||
# 使用 gunicorn 替代 runserver,提高稳定性
|
# 使用 gunicorn 替代 runserver,提高稳定性,并捕获标准输出
|
||||||
command: sh -c "python manage.py migrate && gunicorn --bind 0.0.0.0:8000 config.wsgi:application"
|
command: sh -c "python manage.py collectstatic --noinput && python manage.py migrate && gunicorn --bind 0.0.0.0:8000 --access-logfile - --error-logfile - config.wsgi:application"
|
||||||
volumes:
|
volumes:
|
||||||
- ./backend:/app
|
- ./backend:/app
|
||||||
ports:
|
ports:
|
||||||
|
|||||||
Reference in New Issue
Block a user