mirror of
https://github.com/bellingcat/auto-archiver-api.git
synced 2026-06-13 05:58:35 +03:00
adds health check and new env logic
This commit is contained in:
3
.gitignore
vendored
3
.gitignore
vendored
@@ -7,11 +7,14 @@ secrets
|
|||||||
__pycache
|
__pycache
|
||||||
.pytest_cach
|
.pytest_cach
|
||||||
.env
|
.env
|
||||||
|
.env.dev
|
||||||
|
.env.prod
|
||||||
*.db
|
*.db
|
||||||
redis/data/*
|
redis/data/*
|
||||||
.ipynb_checkpoints*
|
.ipynb_checkpoints*
|
||||||
#temp
|
#temp
|
||||||
tests
|
tests
|
||||||
src/user-groups.yaml
|
src/user-groups.yaml
|
||||||
|
src/user-groups.dev.yaml
|
||||||
wit*
|
wit*
|
||||||
src/crawls
|
src/crawls
|
||||||
@@ -6,6 +6,8 @@ An api that uses celery workers to process URL archive requests via [bellingcat/
|
|||||||
## Development
|
## Development
|
||||||
http://localhost:8004
|
http://localhost:8004
|
||||||
|
|
||||||
|
TODO: update .env file instructions, should use .env.prod and .env.dev and only use .env for always overwriting dev/prod settings.
|
||||||
|
|
||||||
requires `src/.env`
|
requires `src/.env`
|
||||||
|
|
||||||
cd /src
|
cd /src
|
||||||
@@ -37,7 +39,7 @@ Auto-archiver orchestrator files configurations. For each archiving task an orch
|
|||||||
orchestrators:
|
orchestrators:
|
||||||
group1: secrets/orchestration-group1.yaml
|
group1: secrets/orchestration-group1.yaml
|
||||||
group2: secrets/orchestration-group2.yaml
|
group2: secrets/orchestration-group2.yaml
|
||||||
default: secrets/orchestration-default:.yaml
|
default: secrets/orchestration-default:orchestration.yaml
|
||||||
```
|
```
|
||||||
|
|
||||||
## Database migrations
|
## Database migrations
|
||||||
|
|||||||
@@ -1,15 +1,19 @@
|
|||||||
services:
|
services:
|
||||||
web:
|
web:
|
||||||
restart: "no"
|
restart: "no"
|
||||||
|
env_file: src/.env.dev
|
||||||
environment:
|
environment:
|
||||||
- SERVE_LOCAL_ARCHIVE=/app/local_archive # See orchestration.yaml local_storage.save_to
|
- SERVE_LOCAL_ARCHIVE=/app/local_archive # See orchestration.yaml local_storage.save_to
|
||||||
- ALLOWED_ORIGINS=http://localhost:8004,chrome-extension://ojcimmjndnlmmlgnjaeojoebaceokpdp
|
- ALLOWED_ORIGINS=http://localhost:8004,chrome-extension://ojcimmjndnlmmlgnjaeojoebaceokpdp
|
||||||
- API_BEARER_TOKEN=dev-api-bearer-token
|
- API_BEARER_TOKEN=dev-api-bearer-token
|
||||||
|
- USER_GROUPS_FILENAME=user-groups.dev.yaml
|
||||||
|
|
||||||
worker:
|
worker:
|
||||||
restart: "no"
|
restart: "no"
|
||||||
|
env_file: src/.env.dev
|
||||||
|
|
||||||
redis:
|
redis:
|
||||||
restart: "no"
|
restart: "no"
|
||||||
|
env_file: src/.env.dev
|
||||||
ports:
|
ports:
|
||||||
- 6379:6379
|
- 6379:6379
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ x-broker-url: &broker-url "redis://:${REDIS_PASSWORD}@redis:6379/0"
|
|||||||
x-base-setup: &base-setup
|
x-base-setup: &base-setup
|
||||||
build: ./src
|
build: ./src
|
||||||
restart: always
|
restart: always
|
||||||
env_file: src/.env
|
env_file: src/.env.prod
|
||||||
environment:
|
environment:
|
||||||
CELERY_BROKER_URL: *broker-url
|
CELERY_BROKER_URL: *broker-url
|
||||||
CELERY_RESULT_BACKEND: *broker-url
|
CELERY_RESULT_BACKEND: *broker-url
|
||||||
@@ -23,10 +23,15 @@ services:
|
|||||||
- ./src:/app
|
- ./src:/app
|
||||||
depends_on:
|
depends_on:
|
||||||
- redis
|
- redis
|
||||||
|
healthcheck:
|
||||||
|
test: ["CMD", "curl", "-f", "http://localhost:8000/health"]
|
||||||
|
interval: 30s
|
||||||
|
timeout: 10s
|
||||||
|
retries: 3
|
||||||
|
|
||||||
worker:
|
worker:
|
||||||
<<: *base-setup
|
<<: *base-setup
|
||||||
command: celery worker --app=worker.celery --loglevel=info --logfile=logs/celery.log
|
command: celery --app=worker.celery worker --loglevel=info --logfile=logs/celery.log
|
||||||
volumes:
|
volumes:
|
||||||
- ./src:/app
|
- ./src:/app
|
||||||
- /var/run/docker.sock:/var/run/docker.sock
|
- /var/run/docker.sock:/var/run/docker.sock
|
||||||
@@ -41,6 +46,11 @@ services:
|
|||||||
depends_on:
|
depends_on:
|
||||||
- web
|
- web
|
||||||
- redis
|
- redis
|
||||||
|
healthcheck:
|
||||||
|
test: ["CMD", "pipenv", "run", "celery", "-A", "worker.celery", "status"]
|
||||||
|
interval: 30s
|
||||||
|
timeout: 10s
|
||||||
|
retries: 3
|
||||||
|
|
||||||
redis:
|
redis:
|
||||||
image: redis:6-alpine
|
image: redis:6-alpine
|
||||||
@@ -49,6 +59,11 @@ services:
|
|||||||
volumes:
|
volumes:
|
||||||
- "./redis/data:/data"
|
- "./redis/data:/data"
|
||||||
- "./redis/config:/conf"
|
- "./redis/config:/conf"
|
||||||
|
healthcheck:
|
||||||
|
test: ["CMD", "redis-cli", "-a", "${REDIS_PASSWORD}", "ping"]
|
||||||
|
interval: 30s
|
||||||
|
timeout: 10s
|
||||||
|
retries: 3
|
||||||
|
|
||||||
# dashboard service will only launch the dashboard if "--profile flower" is passed to docker compose; or if explicitly called "docker compose up dashboard"
|
# dashboard service will only launch the dashboard if "--profile flower" is passed to docker compose; or if explicitly called "docker compose up dashboard"
|
||||||
dashboard:
|
dashboard:
|
||||||
|
|||||||
@@ -26,6 +26,10 @@ async def home(request: Request):
|
|||||||
return JSONResponse(status)
|
return JSONResponse(status)
|
||||||
|
|
||||||
|
|
||||||
|
@default_router.get("/health")
|
||||||
|
async def health(request: Request):
|
||||||
|
return JSONResponse({"status": "ok"})
|
||||||
|
|
||||||
@default_router.get("/groups", response_model=list[str])
|
@default_router.get("/groups", response_model=list[str])
|
||||||
def get_user_groups(db: Session = Depends(get_db), email=Depends(get_user_auth)):
|
def get_user_groups(db: Session = Depends(get_db), email=Depends(get_user_auth)):
|
||||||
return crud.get_user_groups(db, email)
|
return crud.get_user_groups(db, email)
|
||||||
|
|||||||
Reference in New Issue
Block a user