diff --git a/Dockerfile b/Dockerfile index c23b5cc..4dfc80d 100644 --- a/Dockerfile +++ b/Dockerfile @@ -108,4 +108,4 @@ EXPOSE 8080 ENTRYPOINT ["/app/entrypoint.sh"] # Run gunicorn -CMD ["/usr/local/bin/gunicorn", "-c", "/app/tubesync/gunicorn.py", "--capture-output", "tubesync.wsgi:application"] +CMD ["/usr/local/bin/gunicorn", "-c", "/app/tubesync/gunicorn.py", "-k", "uvicorn.workers.UvicornWorker", "--capture-output", "tubesync.asgi:application"] diff --git a/Pipfile b/Pipfile index 5ce4d05..98de927 100644 --- a/Pipfile +++ b/Pipfile @@ -15,6 +15,10 @@ gunicorn = "*" django-compressor = "*" httptools = "*" youtube-dl = "*" +django-background-tasks = "*" +uvicorn = "*" +uvloop = "*" +django-simple-task = "*" [requires] python_version = "3" diff --git a/Pipfile.lock b/Pipfile.lock index 27b5d07..f6f272f 100644 --- a/Pipfile.lock +++ b/Pipfile.lock @@ -1,7 +1,7 @@ { "_meta": { "hash": { - "sha256": "217d74e65795013e1d5f39efb574d1a0254a109f702fe183d929d5fd537763e0" + "sha256": "83399df34fe306ade38c4e516198bfd67d88e57de8e5366a9038c5eb1ca86036" }, "pipfile-spec": 6, "requires": { @@ -23,6 +23,13 @@ ], "version": "==3.3.1" }, + "click": { + "hashes": [ + "sha256:d2b5255c7c6349bc1bd1e59e08cd12acbbd63ce649f2588755783aa94dfb6b1a", + "sha256:dacca89f4bfadd5de3d7489b7c8a566eee0d3676333fbb50030263894c38c0dc" + ], + "version": "==7.1.2" + }, "django": { "hashes": [ "sha256:14a4b7cd77297fba516fc0d92444cc2e2e388aa9de32d7a68d4a83d58f5a4927", @@ -38,6 +45,19 @@ ], "version": "==1.0.4" }, + "django-background-tasks": { + "hashes": [ + "sha256:e1b19e8d495a276c9d64c5a1ff8b41132f75d2f58e45be71b78650dad59af9de" + ], + "index": "pypi", + "version": "==1.2.5" + }, + "django-compat": { + "hashes": [ + "sha256:3ac9a3bedc56b9365d9eb241bc5157d0c193769bf995f9a78dc1bc24e7c2331b" + ], + "version": "==1.0.15" + }, "django-compressor": { "hashes": [ "sha256:57ac0a696d061e5fc6fbc55381d2050f353b973fb97eee5593f39247bc0f30af", @@ -53,6 +73,14 @@ "index": "pypi", "version": "==0.8.2" }, + "django-simple-task": { + "hashes": [ + "sha256:c70c5fd1db9ba58026ea3a00831c2c1a4d335f29c106321bb2dce643b7a71319", + "sha256:fe6494f5297711f5ec767835163dad3e4f6b751aa8857f0c338e5271a0721a4f" + ], + "index": "pypi", + "version": "==0.1.2" + }, "gunicorn": { "hashes": [ "sha256:1904bb2b8a43658807108d59c3f3d56c2b6121a701161de0ddf9ad140073c626", @@ -61,6 +89,13 @@ "index": "pypi", "version": "==20.0.4" }, + "h11": { + "hashes": [ + "sha256:3c6c61d69c6f13d41f1b80ab0322f1872702a3ba26e12aa864c928f6a43fbaab", + "sha256:ab6c335e1b6ef34b205d5ca3e228c9299cc7218b049819ec84a388c2525e5d87" + ], + "version": "==0.11.0" + }, "httptools": { "hashes": [ "sha256:0a4b1b2012b28e68306575ad14ad5e9120b34fccd02a81eb08838d7e3bbb48be", @@ -177,6 +212,38 @@ ], "version": "==0.4.1" }, + "typing-extensions": { + "hashes": [ + "sha256:7cb407020f00f7bfc3cb3e7881628838e69d8f3fcab2f64742a5e76b2f841918", + "sha256:99d4073b617d30288f569d3f13d2bd7548c3a7e4c8de87db09a9d29bb3a4a60c", + "sha256:dafc7639cde7f1b6e1acc0f457842a83e722ccca8eef5270af2d74792619a89f" + ], + "markers": "python_version < '3.8'", + "version": "==3.7.4.3" + }, + "uvicorn": { + "hashes": [ + "sha256:562ef6aaa8fa723ab6b82cf9e67a774088179d0ec57cb17e447b15d58b603bcf", + "sha256:5836edaf4d278fe67ba0298c0537bdb6398cf359eb644f79e6500ca1aad232b3" + ], + "index": "pypi", + "version": "==0.12.3" + }, + "uvloop": { + "hashes": [ + "sha256:08b109f0213af392150e2fe6f81d33261bb5ce968a288eb698aad4f46eb711bd", + "sha256:123ac9c0c7dd71464f58f1b4ee0bbd81285d96cdda8bc3519281b8973e3a461e", + "sha256:4315d2ec3ca393dd5bc0b0089d23101276778c304d42faff5dc4579cb6caef09", + "sha256:4544dcf77d74f3a84f03dd6278174575c44c67d7165d4c42c71db3fdc3860726", + "sha256:afd5513c0ae414ec71d24f6f123614a80f3d27ca655a4fcf6cabe50994cc1891", + "sha256:b4f591aa4b3fa7f32fb51e2ee9fea1b495eb75b0b3c8d0ca52514ad675ae63f7", + "sha256:bcac356d62edd330080aed082e78d4b580ff260a677508718f88016333e2c9c5", + "sha256:e7514d7a48c063226b7d06617cbb12a14278d4323a065a8d46a7962686ce2e95", + "sha256:f07909cd9fc08c52d294b1570bba92186181ca01fe3dc9ffba68955273dd7362" + ], + "index": "pypi", + "version": "==0.14.0" + }, "whitenoise": { "hashes": [ "sha256:05ce0be39ad85740a78750c86a93485c40f08ad8c62a6006de0233765996e5c7", diff --git a/app/tubesync/asgi.py b/app/tubesync/asgi.py index 1fd3c87..d6443f9 100644 --- a/app/tubesync/asgi.py +++ b/app/tubesync/asgi.py @@ -1,6 +1,7 @@ import os from django.core.asgi import get_asgi_application +from django_simple_task import django_simple_task_middlware os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'tubesync.settings') -application = get_asgi_application() +application = django_simple_task_middlware(get_asgi_application()) diff --git a/app/tubesync/settings.py b/app/tubesync/settings.py index ca42814..a99602b 100644 --- a/app/tubesync/settings.py +++ b/app/tubesync/settings.py @@ -18,6 +18,8 @@ INSTALLED_APPS = [ 'django.contrib.messages', 'django.contrib.staticfiles', 'sass_processor', + 'django_simple_task', + 'background_task', 'common', 'sync', ]