Skip to content

Commit

Permalink
Add Procfile to start all services with one command
Browse files Browse the repository at this point in the history
Starting all services in different terminals is tedious. This PR adds
a Procfile and a honcho dependency that will start up all required
processes in a single command.
  • Loading branch information
Kaustubh Maske Patil authored and Kaustubh Maske Patil committed Sep 20, 2023
1 parent e27cef6 commit b9c8b19
Show file tree
Hide file tree
Showing 4 changed files with 107 additions and 62 deletions.
26 changes: 26 additions & 0 deletions Procfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# this Procfile can be run with `honcho`, and it can start multiple processes
# with a single command. Handy for development. All of the below commands are
# setup to run in dev mode only, and not in prod.
#
# The assumptions here are that:
# - you have redis installed but not running as a background service
# - you have rabbitmq installed but not running as a background service
# - your local gooey-ui repo is at ../gooey-ui/
#
# You can comment any of the processes if you have background services running
# for them. You can also change the path for the `ui` process from `../gooey-ui/`
# to wherever your local gooey-ui directory is.

api: poetry run uvicorn server:app --host 127.0.0.1 --port 8080 --reload

admin: poetry run python manage.py runserver 127.0.0.1:8000

dashboard: poetry run streamlit run Home.py --server.port 8501 --server.headless true

rabbitmq: rabbitmq-server

redis: redis-server

celery: poetry run celery -A celeryapp worker

ui: /bin/zsh -c "cd ../gooey-ui/; PORT=3000 npm run dev"
42 changes: 24 additions & 18 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,37 +1,43 @@
## Setup

* Install [pyenv](https://github.com/pyenv/pyenv) & install the same python version as in our [Dockerfile](Dockerfile)
* Install [poetry](https://python-poetry.org/docs/)
* Create & active a virtualenv (e.g. `poetry shell`)
* Run `poetry install --with dev`
* Create an `.env` file from `.env.example` (Read [12factor.net/config](https://12factor.net/config))
* Run `./manage.py migrate`
* Install the zbar shared library (`brew install zbar`)
* Install [redis](https://redis.io/docs/getting-started/installation/install-redis-on-mac-os/) and [rabbitmq](https://www.rabbitmq.com/install-homebrew.html)

## Run

### API + GUI server

```bash
uvicorn server:app --host 0.0.0.0 --port 8080 --reload
```

Open [localhost:8080](localhost:8080) in your browser
You can start all required processes in one command with Honcho:

### Admin Site

```bash
python3 manage.py runserver 0.0.0.0:8000
```shell
$ poetry run honcho start
```

Open [localhost:8000](localhost:8000) in your browser

The processes that it starts are defined in [`Procfile`](Procfile).
Currently they are these:

### Usage Dashboard
| Service | Port |
| ------- | ---- |
| API + GUI Server | 8080 |
| Admin site | 8000 |
| Usage dashboard | 8501 |
| Redis | 6379 |
| RabbitMQ | 5672 |
| Celery | - |
| UI | 3000 |

```
streamlit run Home.py --server.port 8501
```
This default startup assumes that Redis and RabbitMQ are installed, but not
running as system services (e.g. with `brew services`) already. It also assumes
that the gooey-ui repo can be found at `../gooey-ui/` (adjacent to where the
gooey-server repo sits). You can open the Procfile and comment any of these
if you want to run it in some other way.

Open [localhost:8501](localhost:8501) in your browser
**Note:** the Celery worker must be manually restarted on code changes. You
can do this by stopping and starting Honcho.

## To run any recipe

Expand Down
Loading

0 comments on commit b9c8b19

Please sign in to comment.