Commit 5d28a6e4 authored by ibuler's avatar ibuler

fix(invalid connection) 定期处理长时间连接

1. 减少了处理时间间隔
2. 处理策略更改为 超过 1小时没有动的连接就干掉
parent cba53bba
...@@ -80,15 +80,11 @@ def renderTemplate(script_path, time_file_path, dimensions=(24, 80), templatenam ...@@ -80,15 +80,11 @@ def renderTemplate(script_path, time_file_path, dimensions=(24, 80), templatenam
def kill_invalid_connection(): def kill_invalid_connection():
long_time_logs = []
unfinished_logs = Log.objects.filter(is_finished=False) unfinished_logs = Log.objects.filter(is_finished=False)
now = datetime.datetime.now() now = datetime.datetime.now()
now_timestamp = int(time.mktime(now.timetuple())) now_timestamp = int(time.mktime(now.timetuple()))
for log in unfinished_logs:
if (now - log.start_time).days > 1:
long_time_logs.append(log)
for log in long_time_logs: for log in unfinished_logs:
try: try:
log_file_mtime = int(os.stat(log.log_path).st_mtime) log_file_mtime = int(os.stat(log.log_path).st_mtime)
except OSError: except OSError:
......
...@@ -155,5 +155,5 @@ BOOTSTRAP_COLUMN_COUNT = 10 ...@@ -155,5 +155,5 @@ BOOTSTRAP_COLUMN_COUNT = 10
CRONJOBS = [ CRONJOBS = [
('0 1 * * *', 'jasset.asset_api.asset_ansible_update_all'), ('0 1 * * *', 'jasset.asset_api.asset_ansible_update_all'),
('1 * * * *', 'jlog.log_api.kill_invalid_connection'), ('*/10 * * * *', 'jlog.log_api.kill_invalid_connection'),
] ]
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment