调整服务器参数

main
RogerWork 6 months ago
parent b8154e5ca8
commit 61228b118c
  1. 12
      dingxin_toolbox_drf/settings.py
  2. 8
      mock/views.py

@ -27,7 +27,8 @@ print(BASE_DIR)
# # SERVER_IP = '' # # SERVER_IP = ''
CONFIG = { CONFIG = {
'dev': { 'dev': {
'SERVER_IP': '172.16.1.63', 'SERVER_IP': '172.16.1.114',
'WEB_SERVER_IP': '172.16.1.114',
'DB': { 'DB': {
"HOST": 'home.rogersun.cn', "HOST": 'home.rogersun.cn',
"PORT": 3306, "PORT": 3306,
@ -35,18 +36,19 @@ CONFIG = {
"PASSWORD": "cine123456", "PASSWORD": "cine123456",
"NAME": "dingxin_toolbox", "NAME": "dingxin_toolbox",
}, },
'REDIS_IP': '172.16.1.63' 'REDIS_IP': '172.16.1.114'
}, },
'prd': { 'prd': {
'SERVER_IP': '172.16.1.222', 'SERVER_IP': '172.16.1.63',
'WEB_SERVER_IP': '172.16.1.222',
'DB': { 'DB': {
"HOST": '172.16.1.222', "HOST": '172.16.1.63',
"PORT": 3306, "PORT": 3306,
"USER": "dingxin", "USER": "dingxin",
"PASSWORD": "cine123456", "PASSWORD": "cine123456",
"NAME": "dingxin_toolbox", "NAME": "dingxin_toolbox",
}, },
'REDIS_IP': '172.16.1.222' 'REDIS_IP': '172.16.1.63'
} }
} }

@ -216,8 +216,8 @@ def get_response(request):
# 获取本机 IP 地址: # 获取本机 IP 地址:
def get_local_ip(): def get_local_ip():
ip = CONFIG[ENV]['SERVER_IP'] ip = CONFIG[ENV]['WEB_SERVER_IP']
if CONFIG[ENV]['SERVER_IP'] == '': if CONFIG[ENV]['WEB_SERVER_IP'] == '':
r = runserver() r = runserver()
ip = socket.gethostbyname(socket.gethostname()) ip = socket.gethostbyname(socket.gethostname())
print(ip) print(ip)
@ -272,11 +272,11 @@ def enable_mock(request):
server_ip = get_local_ip() server_ip = get_local_ip()
current_host = db(ip, GET_ZZ_PLATFORM_HOST_SQL)['data'][0]['cinema_common_info_val'] current_host = db(ip, GET_ZZ_PLATFORM_HOST_SQL)['data'][0]['cinema_common_info_val']
if current_host == 'https://zzcs.yinghezhong.com' or current_host == 'https://dy.yinghezhong.com': if current_host == 'https://zzcs.yinghezhong.com' or current_host == 'https://dy.yinghezhong.com':
db_result = db(ip, UPDATE_ZZ_PLATFORM_HOST_SQL, (f'http://{server_ip}:8000',)) db_result = db(ip, UPDATE_ZZ_PLATFORM_HOST_SQL, (f'http://{server_ip}',))
if db_result['result'] > 0: if db_result['result'] > 0:
ZZMockModel.objects.filter(ip=ip).update(**mock_config) ZZMockModel.objects.filter(ip=ip).update(**mock_config)
return JsonResponse({'status': 'success'}) return JsonResponse({'status': 'success'})
if current_host == f'http://{server_ip}:8000': if current_host == f'http://{server_ip}':
ZZMockModel.objects.filter(ip=ip).update(**mock_config) ZZMockModel.objects.filter(ip=ip).update(**mock_config)
return JsonResponse({'status': 'success'}) return JsonResponse({'status': 'success'})
return JsonResponse({'status': 'fail'}) return JsonResponse({'status': 'fail'})

Loading…
Cancel
Save