Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
J
jumpserver
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
ops
jumpserver
Commits
d7bb4c10
Commit
d7bb4c10
authored
Feb 29, 2016
by
ibuler
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix(kill invalid connection) 紧急处理超时连接
1. 紧急修复异常bug 2. 修改处理策略 3. 每10分钟处理一次 ssh连接:超过1小时没有操作就干掉 web:超过1天的就设置完成
parent
3c610668
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
4 additions
and
1 deletion
+4
-1
log_api.py
jlog/log_api.py
+4
-1
No files found.
jlog/log_api.py
View file @
d7bb4c10
...
@@ -15,6 +15,7 @@ from struct import unpack
...
@@ -15,6 +15,7 @@ from struct import unpack
from
subprocess
import
Popen
from
subprocess
import
Popen
from
sys
import
platform
,
prefix
,
stderr
from
sys
import
platform
,
prefix
,
stderr
from
tempfile
import
NamedTemporaryFile
from
tempfile
import
NamedTemporaryFile
from
jumpserver.api
import
logger
from
jinja2
import
FileSystemLoader
,
Template
from
jinja2
import
FileSystemLoader
,
Template
from
jinja2.environment
import
Environment
from
jinja2.environment
import
Environment
...
@@ -86,7 +87,7 @@ def kill_invalid_connection():
...
@@ -86,7 +87,7 @@ def kill_invalid_connection():
for
log
in
unfinished_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
(
'
%
s.log'
%
log
.
log_path
)
.
st_mtime
)
except
OSError
:
except
OSError
:
log_file_mtime
=
0
log_file_mtime
=
0
...
@@ -94,6 +95,7 @@ def kill_invalid_connection():
...
@@ -94,6 +95,7 @@ def kill_invalid_connection():
if
log
.
login_type
==
'ssh'
:
if
log
.
login_type
==
'ssh'
:
try
:
try
:
os
.
kill
(
int
(
log
.
pid
),
9
)
os
.
kill
(
int
(
log
.
pid
),
9
)
except
OSError
:
except
OSError
:
pass
pass
elif
(
now
-
log
.
start_time
)
.
days
<
1
:
elif
(
now
-
log
.
start_time
)
.
days
<
1
:
...
@@ -102,6 +104,7 @@ def kill_invalid_connection():
...
@@ -102,6 +104,7 @@ def kill_invalid_connection():
log
.
is_finished
=
True
log
.
is_finished
=
True
log
.
end_time
=
now
log
.
end_time
=
now
log
.
save
()
log
.
save
()
logger
.
warn
(
'kill log
%
s'
%
log
.
log_path
)
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment