Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

task/WG-236: Websocket notifications (#185) #191

Open
wants to merge 8 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .flake8
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,5 @@ exclude =
geoapi/models/__init__.py
geoapi/tasks/__init__.py
geoapi/schemas/__init__.py
per-file-ignores =
../geoapi/app.py:E402
70 changes: 34 additions & 36 deletions devops/docker-compose.local.yml
Original file line number Diff line number Diff line change
@@ -1,19 +1,27 @@
---
name: geoapi

volumes:
assets:
pgdata:

networks:
geoapi:

services:
redis:
image: redis:7-bookworm
command: redis-server --loglevel warning
container_name: geoapi_redis
hostname: geoapi_redis
healthcheck:
test: redis-cli ping
interval: 5s
timeout: 30s
retries: 5

rabbitmq:
image: rabbitmq:3-management
image: rabbitmq:4-management
ports:
- 15672:15672
networks:
- geoapi
container_name: geoapi_rabbitmq
hostname: geoapi_rabbitmq
environment:
- RABBITMQ_DEFAULT_USER=dev
- RABBITMQ_DEFAULT_PASS=dev
Expand All @@ -28,8 +36,6 @@ services:
image: postgis/postgis:11-3.3-alpine
volumes:
- pgdata:/var/lib/postgresql/data
networks:
- geoapi
container_name: geoapi_postgres
hostname: geoapi_postgres
environment:
Expand All @@ -38,20 +44,18 @@ services:
- POSTGRES_DB=dev

nginx:
image: nginx
image: nginx:stable
ports:
- 8888:80
volumes:
- assets:/assets
- ./local_conf/nginx.conf:/etc/nginx/nginx.conf
networks:
- geoapi

container_name: geoapi_nginx
depends_on:
- backend

workers:
image: taccaci/geoapi-workers:local
networks:
- geoapi
volumes:
- ../:/app
- assets:/assets
Expand All @@ -64,12 +68,12 @@ services:

stdin_open: true
tty: true
container_name: geoapiworkers
hostname: geoapiworkers
container_name: geoapi_workers
hostname: geoapi_workers
command: >
sh -c '
celery -A geoapi.celery_app worker -l info -Q default -n default_worker@geoapi &
celery -A geoapi.celery_app worker -l info -Q heavy --concurrency=6 -n heavy_worker@geoapi &
celery -A geoapi.celery_app worker -l info -Q default -n default_worker@geoapi --uid=nobody --gid=nogroup &
celery -A geoapi.celery_app worker -l info -Q heavy --concurrency=6 -n heavy_worker@geoapi --uid=nobody --gid=nogroup &
wait
'
depends_on:
Expand All @@ -78,8 +82,6 @@ services:

celerybeat:
image: taccaci/geoapi-workers:local
networks:
- geoapi
volumes:
- ../:/app
- assets:/assets
Expand All @@ -88,27 +90,20 @@ services:
- FLASK_APP=/app/geoapi/app.py
- APP_ENV=local
- ASSETS_BASE_DIR=/assets
stdin_open: true
tty: true
container_name: geoapicelerybeat
hostname: geoapicelerybeat
command: "celery -A geoapi.celery_app beat -l info"
container_name: geoapi_celerybeat
hostname: geoapi_celerybeat
command: "celery -A geoapi.celery_app beat -l info --uid=nobody --gid=nogroup"
depends_on:
rabbitmq:
condition: service_healthy

api:
backend:
image: taccaci/geoapi:local
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

README.md

docker exec -it geoapi python initdb.py to docker exec -it geoapi-backend-1 python initdb.py

networks:
- geoapi
volumes:
- ../:/app
- assets:/assets
ports:
- 8000:8000
dns:
- 8.8.8.8
- 8.8.4.4
- 8000-8003:8000
environment:
- MAPILLARY_CLIENT_TOKEN
- FLASK_APP=/app/geoapi/app.py
Expand All @@ -120,8 +115,11 @@ services:
- TAPIS_CLIENT_KEY
stdin_open: true
tty: true
container_name: geoapi
hostname: geoapi
command: "gunicorn -w 4 -b 0.0.0.0:8000 geoapi.app:app -k gevent --reload --timeout 300"
scale: 4
hostname: geoapi_backend
command: "gunicorn -w 1 -b 0.0.0.0:8000 geoapi.app:app -k geventwebsocket.gunicorn.workers.GeventWebSocketWorker --reload --timeout 300"
extra_hosts:
- "host.docker.internal:host-gateway"
depends_on:
redis:
condition: service_healthy
43 changes: 36 additions & 7 deletions devops/local_conf/nginx.conf
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
events {
worker_connections 1024; # increase if you have lots of clients
accept_mutex off; # set to 'on' if nginx worker_processes > 1
use epoll;
worker_connections 1024; # increase if you have lots of clients
accept_mutex off; # set to 'on' if nginx worker_processes > 1
use epoll;
}
http {

Expand All @@ -10,7 +10,17 @@ http {
gzip_types *;
gzip_min_length 250;

upstream geoapi_backend {
ip_hash;
server geoapi-backend-1:8000;
server geoapi-backend-2:8000;
server geoapi-backend-3:8000;
server geoapi-backend-4:8000;
# to scale the app, just add more nodes here!
}

server {

include /etc/nginx/mime.types;
client_max_body_size 1g;

Expand All @@ -26,15 +36,34 @@ http {
add_header 'Content-Length' 0 always;
return 204;
}

rewrite ^/api(.*) /$1 break;
proxy_pass http://geoapi:8000;

proxy_pass http://geoapi_backend/;

proxy_redirect off;

proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header X-Forwarded-Host $server_name;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}

location /socket.io {
proxy_pass http://geoapi_backend/socket.io;

proxy_buffering off;

proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection 'upgrade';
proxy_set_header Connection "Upgrade";

proxy_redirect off;

proxy_set_header Host $host;
proxy_cache_bypass $http_upgrade;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header X-Forwarded-Host $server_name;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}

Expand Down
Loading
Loading