Skip to content

Commit

Permalink
Run Daphne along with uwsgi
Browse files Browse the repository at this point in the history
  • Loading branch information
TamiTakamiya committed Feb 12, 2025
1 parent ee38ccd commit 684c3f0
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 1 deletion.
5 changes: 5 additions & 0 deletions ansible_ai_connect/main/settings/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,11 @@
"csp.middleware.CSPMiddleware",
]

if os.environ.get("CSRF_TRUSTED_ORIGINS"):
CSRF_TRUSTED_ORIGINS = os.environ.get("CSRF_TRUSTED_ORIGINS").split(",")
else:
CSRF_TRUSTED_ORIGINS = ["http://localhost:8000"]

# Allow Prometheus to scrape metrics
ALLOWED_CIDR_NETS = [os.environ.get("ALLOWED_CIDR_NETS", "10.0.0.0/8")]

Expand Down
14 changes: 14 additions & 0 deletions tools/configs/nginx-wisdom.conf
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,12 @@ upstream uwsgi {
server unix:///var/run/uwsgi/ansible_wisdom.sock;
}

upstream daphne {
# server unix:///var/run/daphne/ansible_wisdom.sock;
server 127.0.0.1:9001;
}


server {
listen 8000 default_server;
server_name _;
Expand All @@ -14,4 +20,12 @@ server {
uwsgi_pass uwsgi;
include /etc/nginx/uwsgi_params;
}

location /api/v1/ai/streaming_chat/ {
proxy_pass http://daphne;
proxy_http_version 1.1;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_redirect off;
}
}
14 changes: 14 additions & 0 deletions tools/configs/supervisord.conf
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,20 @@ stdout_logfile_maxbytes = 0
stderr_logfile = /dev/stderr
stderr_logfile_maxbytes = 0

[program:daphne]
; command = /var/www/venv/bin/daphne -u /var/run/daphne/ansible-wisdom.sock ansible_ai_connect.main.asgi:application
command = /var/www/venv/bin/daphne -b 0.0.0.0 -p 9001 ansible_ai_connect.main.asgi:application
autostart = true
autorestart = true
stopwaitsecs = 1
stopsignal = KILL
stopasgroup = true
killasgroup = true
stdout_logfile = /dev/stdout
stdout_logfile_maxbytes = 0
stderr_logfile = /dev/stderr
stderr_logfile_maxbytes = 0

; [program:test]
; command = sleep infinity

Expand Down
3 changes: 2 additions & 1 deletion wisdom-service.Containerfile
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ RUN /var/www/venv/bin/python3.11 -m pip --no-cache-dir install --no-binary=all c

RUN /var/www/venv/bin/python3.11 -m pip --no-cache-dir install -r/var/www/ansible-ai-connect-service/requirements.txt
RUN /var/www/venv/bin/python3.11 -m pip --no-cache-dir install -e/var/www/ansible-ai-connect-service/
RUN mkdir /var/run/uwsgi
RUN mkdir /var/run/uwsgi /var/run/daphne

RUN echo -e "\
{\n\
Expand Down Expand Up @@ -99,6 +99,7 @@ RUN for dir in \
/var/log/supervisor \
/var/run/supervisor \
/var/run/uwsgi \
/var/run/daphne \
/var/www/wisdom \
/var/log/nginx \
/etc/ari \
Expand Down

0 comments on commit 684c3f0

Please sign in to comment.