mirror of
https://github.com/paperless-ngx/paperless-ngx.git
synced 2025-04-02 13:45:10 -05:00
fixed up the docker
This commit is contained in:
parent
b0465e65c3
commit
ae8a048ea6
1
Pipfile
1
Pipfile
@ -28,6 +28,7 @@ django-extensions = ""
|
|||||||
watchdog = "*"
|
watchdog = "*"
|
||||||
channels = "~=3.0"
|
channels = "~=3.0"
|
||||||
channels-redis = "*"
|
channels-redis = "*"
|
||||||
|
daphne = "~=3.0"
|
||||||
|
|
||||||
[dev-packages]
|
[dev-packages]
|
||||||
coveralls = "*"
|
coveralls = "*"
|
||||||
|
4
Pipfile.lock
generated
4
Pipfile.lock
generated
@ -1,7 +1,7 @@
|
|||||||
{
|
{
|
||||||
"_meta": {
|
"_meta": {
|
||||||
"hash": {
|
"hash": {
|
||||||
"sha256": "192d7419b844e6bb81fed793e7766b2ba15f2a016af1a33fc73cf09e12de5fb7"
|
"sha256": "66530e76de7948d8123529eff0b150926aa46a410da8b31e12b6d468e5996e7a"
|
||||||
},
|
},
|
||||||
"pipfile-spec": 6,
|
"pipfile-spec": 6,
|
||||||
"requires": {},
|
"requires": {},
|
||||||
@ -157,7 +157,7 @@
|
|||||||
"sha256:60856f7efa0b1e1b969efa074e8698bd09de4713ecc06e6a4d19d04c66c4a3bd",
|
"sha256:60856f7efa0b1e1b969efa074e8698bd09de4713ecc06e6a4d19d04c66c4a3bd",
|
||||||
"sha256:b43e70d74ff832a634ff6c92badd208824e4530e08b340116517e5aad0aca774"
|
"sha256:b43e70d74ff832a634ff6c92badd208824e4530e08b340116517e5aad0aca774"
|
||||||
],
|
],
|
||||||
"markers": "python_version >= '3.6'",
|
"index": "pypi",
|
||||||
"version": "==3.0.0"
|
"version": "==3.0.0"
|
||||||
},
|
},
|
||||||
"dateparser": {
|
"dateparser": {
|
||||||
|
@ -6,8 +6,8 @@ logfile_maxbytes=50MB ; max main logfile bytes b4 rotation; default 50MB
|
|||||||
logfile_backups=10 ; # of main logfile backups; 0 means none, default 10
|
logfile_backups=10 ; # of main logfile backups; 0 means none, default 10
|
||||||
loglevel=info ; log level; default info; others: debug,warn,trace
|
loglevel=info ; log level; default info; others: debug,warn,trace
|
||||||
|
|
||||||
[program:gunicorn]
|
[program:daphne]
|
||||||
command=gunicorn -c /usr/src/paperless/gunicorn.conf.py -b 0.0.0.0:8000 paperless.wsgi
|
command=daphne -b 0.0.0.0 -p 8000 paperless.asgi:application
|
||||||
user=paperless
|
user=paperless
|
||||||
|
|
||||||
stdout_logfile=/dev/stdout
|
stdout_logfile=/dev/stdout
|
||||||
|
@ -1,31 +1,17 @@
|
|||||||
import json
|
|
||||||
import os
|
import os
|
||||||
|
|
||||||
from asgiref.sync import async_to_sync
|
|
||||||
from channels.auth import AuthMiddlewareStack
|
|
||||||
from channels.generic.websocket import WebsocketConsumer
|
|
||||||
from channels.routing import ProtocolTypeRouter, URLRouter
|
|
||||||
from django.core.asgi import get_asgi_application
|
from django.core.asgi import get_asgi_application
|
||||||
from django.urls import re_path
|
# Fetch Django ASGI application early to ensure AppRegistry is populated
|
||||||
|
# before importing consumers and AuthMiddlewareStack that may import ORM
|
||||||
|
# models.
|
||||||
|
|
||||||
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'paperless.settings')
|
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "paperless.settings")
|
||||||
|
django_asgi_app = get_asgi_application()
|
||||||
|
|
||||||
|
from channels.auth import AuthMiddlewareStack
|
||||||
|
from channels.routing import ProtocolTypeRouter, URLRouter
|
||||||
|
|
||||||
class StatusConsumer(WebsocketConsumer):
|
from paperless.urls import websocket_urlpatterns
|
||||||
def connect(self):
|
|
||||||
self.accept()
|
|
||||||
async_to_sync(self.channel_layer.group_add)('status_updates', self.channel_name)
|
|
||||||
|
|
||||||
def disconnect(self, close_code):
|
|
||||||
async_to_sync(self.channel_layer.group_discard)('status_updates', self.channel_name)
|
|
||||||
|
|
||||||
def status_update(self, event):
|
|
||||||
self.send(json.dumps(event['data']))
|
|
||||||
|
|
||||||
|
|
||||||
websocket_urlpatterns = [
|
|
||||||
re_path(r'ws/status/$', StatusConsumer.as_asgi()),
|
|
||||||
]
|
|
||||||
|
|
||||||
application = ProtocolTypeRouter({
|
application = ProtocolTypeRouter({
|
||||||
"http": get_asgi_application(),
|
"http": get_asgi_application(),
|
||||||
|
16
src/paperless/consumers.py
Normal file
16
src/paperless/consumers.py
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
import json
|
||||||
|
|
||||||
|
from asgiref.sync import async_to_sync
|
||||||
|
from channels.generic.websocket import WebsocketConsumer
|
||||||
|
|
||||||
|
|
||||||
|
class StatusConsumer(WebsocketConsumer):
|
||||||
|
def connect(self):
|
||||||
|
self.accept()
|
||||||
|
async_to_sync(self.channel_layer.group_add)('status_updates', self.channel_name)
|
||||||
|
|
||||||
|
def disconnect(self, close_code):
|
||||||
|
async_to_sync(self.channel_layer.group_discard)('status_updates', self.channel_name)
|
||||||
|
|
||||||
|
def status_update(self, event):
|
||||||
|
self.send(json.dumps(event['data']))
|
@ -307,7 +307,7 @@ CHANNEL_LAYERS = {
|
|||||||
"default": {
|
"default": {
|
||||||
"BACKEND": "channels_redis.core.RedisChannelLayer",
|
"BACKEND": "channels_redis.core.RedisChannelLayer",
|
||||||
"CONFIG": {
|
"CONFIG": {
|
||||||
"hosts": [("127.0.0.1", 6379)],
|
"hosts": [("broker", 6379)],
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
@ -1,11 +1,12 @@
|
|||||||
from django.conf.urls import include, url
|
from django.conf.urls import include, url
|
||||||
from django.contrib import admin
|
from django.contrib import admin
|
||||||
from django.urls import path
|
from django.urls import path, re_path
|
||||||
from django.views.decorators.csrf import csrf_exempt
|
from django.views.decorators.csrf import csrf_exempt
|
||||||
from django.views.generic import RedirectView
|
from django.views.generic import RedirectView
|
||||||
from rest_framework.authtoken import views
|
from rest_framework.authtoken import views
|
||||||
from rest_framework.routers import DefaultRouter
|
from rest_framework.routers import DefaultRouter
|
||||||
|
|
||||||
|
from paperless.consumers import StatusConsumer
|
||||||
from paperless.views import FaviconView
|
from paperless.views import FaviconView
|
||||||
from documents.views import (
|
from documents.views import (
|
||||||
CorrespondentViewSet,
|
CorrespondentViewSet,
|
||||||
@ -65,6 +66,11 @@ urlpatterns = [
|
|||||||
|
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
||||||
|
websocket_urlpatterns = [
|
||||||
|
re_path(r'ws/status/$', StatusConsumer.as_asgi()),
|
||||||
|
]
|
||||||
|
|
||||||
# Text in each page's <h1> (and above login form).
|
# Text in each page's <h1> (and above login form).
|
||||||
admin.site.site_header = 'Paperless'
|
admin.site.site_header = 'Paperless'
|
||||||
# Text at the end of each page's <title>.
|
# Text at the end of each page's <title>.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user