Additional celery beat systemd unit file

This commit is contained in:
Eliot Berriot 2018-04-17 21:26:28 +02:00
parent 6fd77a0a52
commit a37183f57e
No known key found for this signature in database
GPG Key ID: DD6965E2476E5C27
4 changed files with 29 additions and 1 deletions

View File

@ -13,6 +13,8 @@ from __future__ import absolute_import, unicode_literals
from urllib.parse import urlsplit from urllib.parse import urlsplit
import os import os
import environ import environ
from celery.schedules import crontab
from funkwhale_api import __version__ from funkwhale_api import __version__
ROOT_DIR = environ.Path(__file__) - 3 # (/a/b/myfile.py - 3 = /) ROOT_DIR = environ.Path(__file__) - 3 # (/a/b/myfile.py - 3 = /)
@ -334,6 +336,16 @@ CELERY_BROKER_URL = env(
# Your common stuff: Below this line define 3rd party library settings # Your common stuff: Below this line define 3rd party library settings
CELERY_TASK_DEFAULT_RATE_LIMIT = 1 CELERY_TASK_DEFAULT_RATE_LIMIT = 1
CELERY_TASK_TIME_LIMIT = 300 CELERY_TASK_TIME_LIMIT = 300
CELERYBEAT_SCHEDULE = {
'federation.clean_music_cache': {
'task': 'funkwhale_api.federation.tasks.clean_music_cache',
'schedule': crontab(hour='*/2'),
'options': {
'expires': 60 * 2,
},
}
}
import datetime import datetime
JWT_AUTH = { JWT_AUTH = {
'JWT_ALLOW_REFRESH': True, 'JWT_ALLOW_REFRESH': True,

View File

@ -0,0 +1,14 @@
[Unit]
Description=Funkwhale celery beat process
After=redis.service postgresql.service
PartOf=funkwhale.target
[Service]
User=funkwhale
# adapt this depending on the path of your funkwhale installation
WorkingDirectory=/srv/funkwhale/api
EnvironmentFile=/srv/funkwhale/config/.env
ExecStart=/srv/funkwhale/virtualenv/bin/celery -A funkwhale_api.taskapp beat -l INFO
[Install]
WantedBy=multi-user.target

View File

@ -1,3 +1,3 @@
[Unit] [Unit]
Description=Funkwhale Description=Funkwhale
Wants=funkwhale-server.service funkwhale-worker.service Wants=funkwhale-server.service funkwhale-worker.service funkwhale-beat.service

View File

@ -13,11 +13,13 @@ First, download the sample unitfiles:
curl -L -o "/etc/systemd/system/funkwhale.target" "https://code.eliotberriot.com/funkwhale/funkwhale/raw/|version|/deploy/funkwhale.target" curl -L -o "/etc/systemd/system/funkwhale.target" "https://code.eliotberriot.com/funkwhale/funkwhale/raw/|version|/deploy/funkwhale.target"
curl -L -o "/etc/systemd/system/funkwhale-server.service" "https://code.eliotberriot.com/funkwhale/funkwhale/raw/|version|/deploy/funkwhale-server.service" curl -L -o "/etc/systemd/system/funkwhale-server.service" "https://code.eliotberriot.com/funkwhale/funkwhale/raw/|version|/deploy/funkwhale-server.service"
curl -L -o "/etc/systemd/system/funkwhale-worker.service" "https://code.eliotberriot.com/funkwhale/funkwhale/raw/|version|/deploy/funkwhale-worker.service" curl -L -o "/etc/systemd/system/funkwhale-worker.service" "https://code.eliotberriot.com/funkwhale/funkwhale/raw/|version|/deploy/funkwhale-worker.service"
curl -L -o "/etc/systemd/system/funkwhale-beat.service" "https://code.eliotberriot.com/funkwhale/funkwhale/raw/|version|/deploy/funkwhale-beat.service"
This will download three unitfiles: This will download three unitfiles:
- ``funkwhale-server.service`` to launch the funkwhale web server - ``funkwhale-server.service`` to launch the funkwhale web server
- ``funkwhale-worker.service`` to launch the funkwhale task worker - ``funkwhale-worker.service`` to launch the funkwhale task worker
- ``funkwhale-beat.service`` to launch the funkwhale task beat (this is for recurring tasks)
- ``funkwhale.target`` to easily stop and start all of the services at once - ``funkwhale.target`` to easily stop and start all of the services at once
You can of course review and edit them to suit your deployment scenario You can of course review and edit them to suit your deployment scenario