Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Maják
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container registry
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
TO
Maják
Commits
9aa26662
Commit
9aa26662
authored
3 years ago
by
jan.bednarik
Browse files
Options
Downloads
Patches
Plain Diff
Celery setup improvements
parent
3e109f88
No related branches found
No related tags found
2 merge requests
!442
Release
,
!432
Feature/majak imports
Pipeline
#7427
passed
3 years ago
Stage: build
Changes
4
Pipelines
2
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
Dockerfile
+0
-1
0 additions, 1 deletion
Dockerfile
Makefile
+4
-0
4 additions, 0 deletions
Makefile
README.md
+8
-0
8 additions, 0 deletions
README.md
majak/settings/base.py
+4
-2
4 additions, 2 deletions
majak/settings/base.py
with
16 additions
and
3 deletions
Dockerfile
+
0
−
1
View file @
9aa26662
...
...
@@ -29,7 +29,6 @@ ENV DJANGO_SETTINGS_MODULE "majak.settings.production"
# fake values for required env variables used to run collectstatic during build
RUN
DJANGO_SECRET_KEY
=
x
DATABASE_URL
=
postgres://x/x
DJANGO_ALLOWED_HOSTS
=
x
\
OIDC_RP_CLIENT_ID
=
x
OIDC_RP_CLIENT_SECRET
=
x
OIDC_RP_REALM_URL
=
x
\
CELERY_BROKER_URL
=
x
CELERY_RESULT_BACKEND
=
x
\
python manage.py collectstatic
EXPOSE
8000
...
...
This diff is collapsed.
Click to expand it.
Makefile
+
4
−
0
View file @
9aa26662
...
...
@@ -15,6 +15,7 @@ help:
@
echo
"Application:"
@
echo
" run Run the application on port
${
PORT
}
"
@
echo
" shell Run Django shell"
@
echo
" worker Run Celery worker"
@
echo
""
@
echo
"Database:"
@
echo
" migrations Generate migrations"
...
...
@@ -44,6 +45,9 @@ run: venv
shell
:
venv
${
VENV
}
/bin/python manage.py shell_plus
worker
:
venv
${
VENV
}
/bin/celery
-A
majak worker
--pool
solo
-E
-l
INFO
migrations
:
venv
${
VENV
}
/bin/python manage.py makemigrations
...
...
This diff is collapsed.
Click to expand it.
README.md
+
8
−
0
View file @
9aa26662
...
...
@@ -100,6 +100,7 @@ Appka přidává management command `update_callendars`, který stahuje a updatu
kalendáře. Je třeba ho pravidelně volat na pozadí (přes CRON).
### Celery (Import z Jekyllu)
Import z Jekyll GitHub repozitářů pirátských webů je řešen asynchroně přes Celery.
Celery využívá Redis, který může běžet např. lokálně, typicky 6379:
V envu pak je pak potřeba mít nastavený Celery broker:
...
...
@@ -110,10 +111,15 @@ CELERY_RESULT_BACKEND=redis://localhost:6379/6
```
Aby se celery tasky vykonávaly, je potřeba pustit celery v terminálu:
```
celery -A majak worker
```
Pokud není zadán
`CELERY_BROKER_URL`
, tak se automaticky nastaví
`CELERY_TASK_ALWAYS_EAGER = True`
, čímž se tasky vykonají synchronně přímo v
procesu webserveru.
### Stránka 404
Pokud je třeba vlastní 404 pro web, stačí do kořenové
`xxxHomePage`
webu
...
...
@@ -142,6 +148,8 @@ V produkci musí být navíc nastaveno:
| --- | --- | --- |
|
`DJANGO_SECRET_KEY`
| | tajný šifrovací klíč |
|
`DJANGO_ALLOWED_HOSTS`
| | allowed hosts (více hodnot odděleno čárkami) |
|
`CELERY_BROKER_URL`
| | URL pro Celery Broker |
|
`CELERY_RESULT_BACKEND`
| | URL pro Celery Result Backend |
Různé:
...
...
This diff is collapsed.
Click to expand it.
majak/settings/base.py
+
4
−
2
View file @
9aa26662
...
...
@@ -192,8 +192,10 @@ CACHES["renditions"]["TIMEOUT"] = 60 * 60 * 24
# CELERY
# ------------------------------------------------------------------------------
CELERY_BROKER_URL
=
env
.
str
(
"
CELERY_BROKER_URL
"
)
CELERY_RESULT_BACKEND
=
env
.
str
(
"
CELERY_RESULT_BACKEND
"
)
CELERY_BROKER_URL
=
env
.
str
(
"
CELERY_BROKER_URL
"
,
default
=
""
)
if
not
CELERY_BROKER_URL
:
CELERY_TASK_ALWAYS_EAGER
=
True
CELERY_RESULT_BACKEND
=
env
.
str
(
"
CELERY_RESULT_BACKEND
"
,
default
=
""
)
CELERY_ACCEPT_CONTENT
=
[
"
application/json
"
]
CELERY_RESULT_SERIALIZER
=
"
json
"
CELERY_TASK_SERIALIZER
=
"
json
"
...
...
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