Prepare for queue

This commit is contained in:
Kumi 2019-02-01 16:49:55 +00:00
parent e07968df09
commit cb9e16371d
5 changed files with 29 additions and 2 deletions

12
misc/celery.service Normal file
View file

@ -0,0 +1,12 @@
[Unit]
Description=Celery Service
After=network.target
[Service]
User=vpn
Group=vpn
WorkingDirectory=/opt/vpnmanager
ExecStart=/bin/sh -c '/usr/local/bin/celery -A vpnmanager worker -l info'
[Install]
WantedBy=multi-user.target

View file

@ -1,8 +1,8 @@
#!/bin/bash #!/bin/bash
sudo apt update sudo apt update
sudo apt install -y python3-pip npm openvpn easy-rsa postfix sudo apt install -y python3-pip npm openvpn easy-rsa postfix rabbitmq-server
sudo pip3 install -U django django-cron uwsgi django-two-factor-auth django-bootstrap-form twilio argon2_cffi GitPython sudo pip3 install -U django django-cron uwsgi celery django-celery-results django-two-factor-auth django-bootstrap-form twilio argon2_cffi GitPython
sudo useradd vpn sudo useradd vpn
git submodule init git submodule init
git submodule update git submodule update

View file

@ -0,0 +1,3 @@
from .celery import app as celery_app
__all__ = ('celery_app', )

7
vpnmanager/celery.py Normal file
View file

@ -0,0 +1,7 @@
import os
from celery import Celery
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'vpnmanager.settings')
app = Celery('vpnmanager')
app.config_from_object('django.conf:settings', namespace='CELERY')
app.autodiscover_tasks()

View file

@ -23,6 +23,7 @@ TWILIO_CALLER_ID = "+43676800555559"
INSTALLED_APPS = [ INSTALLED_APPS = [
'bootstrapform', 'bootstrapform',
'django_otp', 'django_otp',
'django_celery_results',
'django_otp.plugins.otp_static', 'django_otp.plugins.otp_static',
'django_otp.plugins.otp_totp', 'django_otp.plugins.otp_totp',
'two_factor', 'two_factor',
@ -141,3 +142,7 @@ PASSWORD_HASHERS = [
CRON_CLASSES = [ CRON_CLASSES = [
"manager.cronjobs.FetchRemoteCron", "manager.cronjobs.FetchRemoteCron",
] ]
# Celery config
CELERY_RESULT_BACKEND = 'django-db'