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
a1b80f5f
Commit
a1b80f5f
authored
Dec 20, 2018
by
ibuler
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[Update] 清理task adhoc和history
parent
7773c302
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
14 additions
and
2 deletions
+14
-2
tasks.py
apps/assets/tasks.py
+0
-2
tasks.py
apps/ops/tasks.py
+14
-0
No files found.
apps/assets/tasks.py
View file @
a1b80f5f
...
...
@@ -4,8 +4,6 @@ import re
import
os
from
celery
import
shared_task
from
ops.celery
import
app
as
celery_app
from
django.core.cache
import
cache
from
django.utils.translation
import
ugettext
as
_
from
common.utils
import
capacity_convert
,
\
...
...
apps/ops/tasks.py
View file @
a1b80f5f
...
...
@@ -2,6 +2,7 @@
from
celery
import
shared_task
,
subtask
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
logger
=
get_logger
(
__file__
)
...
...
@@ -34,6 +35,19 @@ def run_command_execution(cid, **kwargs):
return
execution
.
run
()
@shared_task
@register_as_period_task
(
interval
=
3600
*
24
)
@after_app_shutdown_clean
def
clean_tasks_adhoc_period
():
logger
.
debug
(
"Start clean task adhoc and run history"
)
tasks
=
Task
.
objects
.
all
()
for
task
in
tasks
:
adhoc
=
task
.
adhoc
.
all
()
.
order_by
(
'-date_created'
)[
5
:]
for
ad
in
adhoc
:
ad
.
history
.
all
()
.
delete
()
ad
.
delete
()
@shared_task
def
hello
(
name
,
callback
=
None
):
print
(
"Hello {}"
.
format
(
name
))
...
...
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