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
49a16655
Unverified
Commit
49a16655
authored
Jan 08, 2019
by
老广
Committed by
GitHub
Jan 08, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Bugfix (#2327)
* [Bugfix] 修复两个配置文件冲突问题 * [Update] Docker中不再提供配置文件
parent
0e1d3f93
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
45 additions
and
20 deletions
+45
-20
Dockerfile
Dockerfile
+0
-1
conf.py
apps/jumpserver/conf.py
+20
-16
tasks.py
apps/ops/tasks.py
+22
-1
tasks.py
apps/terminal/tasks.py
+1
-1
jms
jms
+2
-1
No files found.
Dockerfile
View file @
49a16655
...
...
@@ -12,7 +12,6 @@ RUN yum -y install epel-release && cd /tmp/requirements && \
RUN
cd
/tmp/requirements
&&
pip
install
-r
requirements.txt
COPY
. /opt/jumpserver
COPY
config_example.yml /opt/jumpserver/config.yml
VOLUME
/opt/jumpserver/data
VOLUME
/opt/jumpserver/logs
...
...
apps/jumpserver/conf.py
View file @
49a16655
...
...
@@ -340,29 +340,33 @@ defaults = {
}
def
load_user_config
():
sys
.
path
.
insert
(
0
,
PROJECT_DIR
)
config
=
Config
(
PROJECT_DIR
,
defaults
)
loaded
=
False
for
i
in
[
'config.yml'
,
'config.yaml'
]:
if
os
.
path
.
isfile
(
os
.
path
.
join
(
config
.
root_path
,
i
)):
config
.
from_yaml
(
i
)
loaded
=
True
def
load_from_object
(
config
):
try
:
from
config
import
config
as
c
config
.
from_object
(
c
)
loaded
=
True
return
True
except
ImportError
:
pass
return
False
try
:
config
.
from_yaml
(
'config.yml'
)
loaded
=
True
except
IOError
:
pass
def
load_from_yml
(
config
):
for
i
in
[
'config.yml'
,
'config.yaml'
]:
if
not
os
.
path
.
isfile
(
os
.
path
.
join
(
config
.
root_path
,
i
)):
continue
loaded
=
config
.
from_yaml
(
i
)
if
loaded
:
return
True
return
False
def
load_user_config
():
sys
.
path
.
insert
(
0
,
PROJECT_DIR
)
config
=
Config
(
PROJECT_DIR
,
defaults
)
loaded
=
load_from_object
(
config
)
if
not
loaded
:
loaded
=
load_from_yml
(
config
)
if
not
loaded
:
msg
=
"""
...
...
apps/ops/tasks.py
View file @
49a16655
# coding: utf-8
import
os
from
celery
import
shared_task
,
subtask
from
django.utils
import
timezone
from
common.utils
import
get_logger
,
get_object_or_none
from
.celery.utils
import
register_as_period_task
,
after_app_shutdown_clean
from
.models
import
Task
,
CommandExecution
from
.models
import
Task
,
CommandExecution
,
CeleryTask
logger
=
get_logger
(
__file__
)
...
...
@@ -48,6 +51,24 @@ def clean_tasks_adhoc_period():
ad
.
delete
()
@shared_task
@register_as_period_task
(
interval
=
3600
*
24
)
@after_app_shutdown_clean
def
clean_celery_tasks_period
():
logger
.
debug
(
"Start clean celery task history"
)
one_month_ago
=
timezone
.
now
()
-
timezone
.
timedelta
(
days
=
30
)
tasks
=
CeleryTask
.
objects
.
filter
(
date_start__lt
=
one_month_ago
)
for
task
in
tasks
:
if
os
.
path
.
isfile
(
task
.
full_log_path
):
try
:
os
.
remove
(
task
.
full_log_path
)
except
(
FileNotFoundError
,
PermissionError
):
pass
task
.
delete
()
tasks
=
CeleryTask
.
objects
.
filter
(
date_start__isnull
=
True
)
tasks
.
delete
()
@shared_task
def
hello
(
name
,
callback
=
None
):
print
(
"Hello {}"
.
format
(
name
))
...
...
apps/terminal/tasks.py
View file @
49a16655
...
...
@@ -25,7 +25,7 @@ logger = get_task_logger(__name__)
@after_app_ready_start
@after_app_shutdown_clean
def
delete_terminal_status_period
():
yesterday
=
timezone
.
now
()
-
datetime
.
timedelta
(
days
=
3
)
yesterday
=
timezone
.
now
()
-
datetime
.
timedelta
(
days
=
1
)
Status
.
objects
.
filter
(
date_created__lt
=
yesterday
)
.
delete
()
...
...
jms
View file @
49a16655
...
...
@@ -15,7 +15,8 @@ sys.path.append(BASE_DIR)
from
apps
import
__version__
try
:
from
config
import
config
as
CONFIG
from
apps.jumpserver.conf
import
load_user_config
CONFIG
=
load_user_config
()
except
ImportError
:
print
(
"Could not find config file, `cp config_example.py config.py`"
)
sys
.
exit
(
1
)
...
...
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