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

App startup improvement #217

Merged
merged 2 commits into from
Sep 10, 2023
Merged
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
30 changes: 27 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -122,11 +122,26 @@ compile_relay: compose
# Run
# =========================================================


.PHONY: cluster
cluster: compose
docker-compose up -d web nginx worker


.PHONY: up
up: cluster


.PHONY: down
down: compose
docker-compose down


# run backend and frontend. This starts uvicorn for asgi+websockers
# and nginx to serve static files
.PHONY: server
server: compose
docker-compose up web nginx
server: cluster
@docker-compose logs -f --tail=10 web nginx


# run django debug server, backup in case nginx ever breaks
Expand All @@ -137,7 +152,16 @@ runserver: compose
# run worker
.PHONY: worker
worker: compose
${DOCKER_COMPOSE_RUN} celery.sh
@docker-compose logs -f --tail=10 worker

# reset worker (for code refresh)
.PHONY: worker-reset
worker-reset: compose
@echo stopping workers...
@docker-compose up -d --scale worker=0
@echo restarting worker...
@docker-compose up -d --scale worker=1


# =========================================================
# Shells
Expand Down
26 changes: 22 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -135,23 +135,41 @@ OPENAI_API_KEY=YOUR_KEY_HERE
```

### Build and run the dev image.
Set NO_IMAGE_BUILD=1 to rebuild the image
Set NO_IMAGE_BUILD=1 to skip rebuilding the image
```
make dev_setup
```

### Run the dev server & worker
Set NO_IMAGE_BUILD=1 to rebuild the image
### Run the docker cluster
Set NO_IMAGE_BUILD=1 to skip rebuilding the image

```bash
make cluster
```

### View logs

Web server logs
```bash
make server
```

Start a worker
Agent worker logs
```bash
make worker
```

### Halt the docker cluster

```bash
make down
```

### recycle workers
Recycle workers to deploy new code changes.
```bash
make worker-reset
```

## Usage

Expand Down
5 changes: 5 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ services:
POSTGRES_USER: ix
POSTGRES_DB: ix
POSTGRES_HOST_AUTH_METHOD: trust
volumes:
- postgres_data:/var/lib/postgresql/data

web:
image: ghcr.io/kreneskyp/ix/sandbox:latest
Expand Down Expand Up @@ -57,3 +59,6 @@ services:
redis:
image: redis/redis-stack-server:latest


volumes:
postgres_data:
Loading