Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
H
hub
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Package registry
Operate
Terraform modules
Analyze
Contributor analytics
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
thomasDOTwtf
hub
Commits
9f4c7ac2
Commit
9f4c7ac2
authored
1 year ago
by
HeJ
Browse files
Options
Downloads
Patches
Plain Diff
Docker: use housekeeping's integrated forever mode
parent
dc001fcf
No related branches found
No related tags found
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
deployment/docker/app.sh
+5
-5
5 additions, 5 deletions
deployment/docker/app.sh
src/core/management/commands/housekeeping.py
+8
-2
8 additions, 2 deletions
src/core/management/commands/housekeeping.py
with
13 additions
and
7 deletions
deployment/docker/app.sh
+
5
−
5
View file @
9f4c7ac2
...
...
@@ -99,12 +99,12 @@ if [ "$1" == "shell" -o "$1" == "createsuperuser" -o "$1" == "test" ]; then
fi
if
[
"
$1
"
==
"housekeeping"
]
;
then
while
true
;
do
date
interval
=
"
${
HOUSEKEEPING_SLEEP_SECONDS
:-
300
}
"
if
[
"
$interval
"
-gt
0
]
;
then
python3
$APP_HOME
/manage.py housekeeping
--forever
--forever-delay
=
"
$interval
"
else
python3
$APP_HOME
/manage.py housekeeping
sleep
"
${
HOUSEKEEPING_SLEEP_SECONDS
:-
300
}
"
echo
done
fi
fi
if
[
"
$1
"
==
"build"
]
;
then
...
...
This diff is collapsed.
Click to expand it.
src/core/management/commands/housekeeping.py
+
8
−
2
View file @
9f4c7ac2
import
time
from
django.core.management.base
import
BaseCommand
from
django.core.management.base
import
BaseCommand
,
CommandError
from
django.utils
import
timezone
from
...models.messages
import
DirectMessage
...
...
@@ -63,6 +63,12 @@ class Command(BaseCommand):
def
handle
(
self
,
*
args
,
**
options
):
# call _do_housekeeping repeatedly (unless --forever is not set)
forever
=
options
.
get
(
'
forever
'
)
forever_delay
=
options
.
get
(
'
forever_delay
'
,
'
0
'
)
if
forever
:
if
forever_delay
<=
0
:
raise
CommandError
(
'
The --forever-delay value must a positive value (in seconds).
'
)
print
(
f
'
Running housekeeping forever each
{
forever_delay
}
s:
'
,
end
=
'
\n\n
'
)
while
True
:
if
forever
:
print
(
timezone
.
now
().
isoformat
())
...
...
@@ -72,7 +78,7 @@ class Command(BaseCommand):
if
forever
:
print
()
# empty line
try
:
time
.
sleep
(
options
.
get
(
'
forever_delay
'
)
)
time
.
sleep
(
forever_delay
)
except
KeyboardInterrupt
:
print
(
'
Aborted.
'
)
break
...
...
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