整理线上配置

main
RogerWork 9 months ago
parent 13defdf973
commit 77023d8538
  1. 13
      update/views.py

@ -23,6 +23,7 @@ from update.utils.cmd_extcute import UpdateCommandUtil, UpdateConfigUtil
from update.utils.db_compare import DbCompare
from update.utils.client_util import ClientUtil
# from consumers import UpdateConsumer
@ -135,7 +136,7 @@ def update_cine(request):
print('redis存在key', redis_key)
return JsonResponse({'result': 'fail', 'ip': cinema_ip, 'msg': '该影院正在升级中,请稍后再试!'})
else:
redis_conn.set(redis_key, json.dumps(update_status), 10*60)
redis_conn.set(redis_key, json.dumps(update_status), 5 * 60)
print('update_status', update_status)
@ -154,11 +155,12 @@ def update_cine(request):
print('获取并写入cine.sql')
try:
update_status['git']['result'] = 'running'
redis_conn.set(redis_key, json.dumps(update_status), 5 * 60)
git_util = GitUtil(short_release)
git_output = git_util.handle_create_cine()
update_status['git']['result'] = 'success'
update_status['git']['msg'] = git_output
redis_conn.set(redis_key, json.dumps(update_status), 5*60)
redis_conn.set(redis_key, json.dumps(update_status), 5 * 60)
except Exception as e:
print('git', e)
update_status['git']['result'] = 'fail'
@ -170,6 +172,7 @@ def update_cine(request):
print('执行setup')
try:
update_status['setup']['result'] = 'running'
redis_conn.set(redis_key, json.dumps(update_status), 5 * 60)
setup_list = list(set(cmd_list) & set(cmd_dict['setup']))
update_cmd = UpdateCommandUtil()
result, setup_output = update_cmd.exec_cmd_by_type(cinema_ip, 'setup', setup_list, short_release)
@ -191,6 +194,7 @@ def update_cine(request):
print('数据库对比')
try:
update_status['sql']['result'] = 'running'
redis_conn.set(redis_key, json.dumps(update_status), 5 * 60)
db_compare = DbCompare(cinema_ip, short_release)
sql_output = db_compare.exec_diff_sql()
update_status['sql']['result'] = 'success'
@ -207,6 +211,7 @@ def update_cine(request):
print('执行config(teardown前)')
try:
update_status['config']['result'] = 'running'
redis_conn.set(redis_key, json.dumps(update_status), 5 * 60)
config_list = list(set(cmd_list) & set(cmd_dict['config']))
update_config = UpdateConfigUtil(cinema_ip, config_list, True)
config_before_output = update_config.exec_config()
@ -226,6 +231,7 @@ def update_cine(request):
print('执行teardown')
try:
update_status['teardown']['result'] = 'running'
redis_conn.set(redis_key, json.dumps(update_status), 5 * 60)
update_cmd = UpdateCommandUtil()
result, teardown_output = update_cmd.exec_cmd_by_type(cinema_ip, 'teardown', teardown_list, short_release)
if result is False:
@ -244,6 +250,7 @@ def update_cine(request):
print('执行config(teardown后)')
try:
update_status['config']['result'] = 'running'
redis_conn.set(redis_key, json.dumps(update_status), 5 * 60)
config_list = list(set(cmd_list) & set(cmd_dict['config']))
update_config = UpdateConfigUtil(cinema_ip, config_list, False)
config_after_output = update_config.exec_config()
@ -262,6 +269,8 @@ def update_cine(request):
if len(client_list) > 0:
print('传输客户端1')
try:
update_status['client']['result'] = 'running'
redis_conn.set(redis_key, json.dumps(update_status), 5 * 60)
client_release = ClientUtil()
client_release.client_process(cinema_ip, short_release)
update_status['client']['result'] = 'success'

Loading…
Cancel
Save