mirror of https://github.com/openspug/spug
F 修复任务调度可能丢失数据库连接的问题
parent
4e5fe4046f
commit
a7cef08176
|
@ -6,6 +6,7 @@ from threading import Thread
|
||||||
from libs.ssh import SSH
|
from libs.ssh import SSH
|
||||||
from apps.host.models import Host
|
from apps.host.models import Host
|
||||||
from apps.setting.utils import AppSetting
|
from apps.setting.utils import AppSetting
|
||||||
|
from django.db import close_old_connections
|
||||||
import subprocess
|
import subprocess
|
||||||
import time
|
import time
|
||||||
|
|
||||||
|
@ -30,6 +31,7 @@ def host_executor(q, host, pkey, command):
|
||||||
|
|
||||||
|
|
||||||
def dispatch(command, targets):
|
def dispatch(command, targets):
|
||||||
|
close_old_connections()
|
||||||
threads, pkey, q = [], AppSetting.get('private_key'), Queue()
|
threads, pkey, q = [], AppSetting.get('private_key'), Queue()
|
||||||
for t in targets:
|
for t in targets:
|
||||||
if t == 'local':
|
if t == 'local':
|
||||||
|
|
Loading…
Reference in New Issue