Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
beat.web
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
beat
beat.web
Commits
139b0da2
Commit
139b0da2
authored
8 years ago
by
André Anjos
Browse files
Options
Downloads
Patches
Plain Diff
[backend] Allow user to set path to clean-up
parent
d4045277
No related branches found
Branches containing commit
No related tags found
Tags containing commit
1 merge request
!194
Scheduler
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
beat/web/backend/management/commands/cleanup_cache.py
+9
-3
9 additions, 3 deletions
beat/web/backend/management/commands/cleanup_cache.py
with
9 additions
and
3 deletions
beat/web/backend/management/commands/cleanup_cache.py
+
9
−
3
View file @
139b0da2
...
@@ -46,12 +46,18 @@ class Command(BaseCommand):
...
@@ -46,12 +46,18 @@ class Command(BaseCommand):
parser
.
add_argument
(
'
--olderthan
'
,
type
=
int
,
metavar
=
'
MINUTES
'
,
parser
.
add_argument
(
'
--olderthan
'
,
type
=
int
,
metavar
=
'
MINUTES
'
,
default
=
0
,
help
=
'
All files which are older than this value
'
\
default
=
0
,
help
=
'
All files which are older than this value
'
\
'
in *minutes* and are not locked or being used by active
'
\
'
in *minutes* and are not locked or being used by active
'
\
'
experiments (running or scheduled) will be deleted
'
)
'
experiments (running or scheduled) will be deleted
'
\
'
[default: %(default)s]
'
)
parser
.
add_argument
(
'
--delete
'
,
action
=
'
store_true
'
,
default
=
False
,
parser
.
add_argument
(
'
--delete
'
,
action
=
'
store_true
'
,
default
=
False
,
help
=
'
By default we only list cache files that will
'
\
help
=
'
By default we only list cache files that will
'
\
'
be erased. If you pass this flag, then we really erase them
'
)
'
be erased. If you pass this flag, then we really erase them
'
)
parser
.
add_argument
(
'
--path
'
,
default
=
settings
.
CACHE_ROOT
,
help
=
'
By default, we erase the CACHE path on your settings. Set
'
\
'
this flag if you want to operate on a different path
'
\
'
[default: %(default)s]
'
)
def
handle
(
self
,
*
ignored
,
**
arguments
):
def
handle
(
self
,
*
ignored
,
**
arguments
):
...
@@ -62,11 +68,11 @@ class Command(BaseCommand):
...
@@ -62,11 +68,11 @@ class Command(BaseCommand):
if
arguments
[
'
verbosity
'
]
==
1
:
logger
.
setLevel
(
logging
.
INFO
)
if
arguments
[
'
verbosity
'
]
==
1
:
logger
.
setLevel
(
logging
.
INFO
)
elif
arguments
[
'
verbosity
'
]
>=
2
:
logger
.
setLevel
(
logging
.
DEBUG
)
elif
arguments
[
'
verbosity
'
]
>=
2
:
logger
.
setLevel
(
logging
.
DEBUG
)
deleted
=
cleanup_cache
(
settings
.
CACHE_ROOT
,
deleted
=
cleanup_cache
(
arguments
[
'
path
'
]
,
age_in_minutes
=
arguments
[
'
olderthan
'
],
age_in_minutes
=
arguments
[
'
olderthan
'
],
delete
=
arguments
[
'
delete
'
])
delete
=
arguments
[
'
delete
'
])
if
not
arguments
[
'
delete
'
]:
if
not
arguments
[
'
delete
'
]:
print
(
"
%d cache files can be deleted
"
%
len
(
deleted
))
print
(
"
%d cache files can be deleted
"
%
len
(
deleted
))
for
k
in
deleted
:
for
k
in
deleted
:
print
(
os
.
path
.
join
(
settings
.
CACHE_ROOT
,
k
))
print
(
os
.
path
.
join
(
arguments
[
'
path
'
]
,
k
))
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment