Skip to content

Commit

Permalink
Replace Gunicorn by Waitress
Browse files Browse the repository at this point in the history
  • Loading branch information
sbrunner committed Nov 22, 2024
1 parent 94cc305 commit 0b3e8bb
Show file tree
Hide file tree
Showing 14 changed files with 142 additions and 205 deletions.
4 changes: 1 addition & 3 deletions .dockerignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,7 @@
!MANIFEST.in
!tilecloud_chain/*
!docker/run
!development.ini
!production.ini
!gunicorn.conf.py
!application.ini
!package*.json
!.nvmrc
!screenshot.js
10 changes: 2 additions & 8 deletions .github/workflows/main.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ jobs:
path: /tmp/pre-commit.patch
retention-days: 1
if: failure()

- name: Print environment information
run: c2cciutils-env
env:
Expand All @@ -64,20 +65,13 @@ jobs:

- name: Checks
run: make checks
- run: git diff --exit-code --patch > /tmp/ruff.patch || true && git reset --hard
if: failure()
- uses: actions/upload-artifact@v4
with:
name: Apply Ruff lint fix.patch
path: /tmp/ruff.patch
retention-days: 1
if: failure()

- name: Tests
run: make tests

- run: c2cciutils-docker-logs
if: always()

- uses: actions/upload-artifact@v4
with:
name: results
Expand Down
11 changes: 4 additions & 7 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ RUN --mount=type=cache,target=/var/lib/apt/lists \

# From c2cwsgiutils

CMD ["gunicorn", "--paste=/app/production.ini"]
CMD ["/venv/bin/pserve", "c2c:///app/application.ini"]

ENV LOG_TYPE=console \
DEVELOPMENT=0 \
Expand Down Expand Up @@ -86,7 +86,7 @@ ENV TILEGENERATION_CONFIGFILE=/etc/tilegeneration/config.yaml \
TILECLOUD_CHAIN_LOG_LEVEL=INFO \
TILECLOUD_LOG_LEVEL=INFO \
C2CWSGIUTILS_LOG_LEVEL=WARN \
GUNICORN_LOG_LEVEL=WARN \
WAITRESS_LOG_LEVEL=INFO \
SQL_LOG_LEVEL=WARN \
OTHER_LOG_LEVEL=WARN \
VISIBLE_ENTRY_POINT=/ \
Expand All @@ -96,7 +96,8 @@ ENV TILEGENERATION_CONFIGFILE=/etc/tilegeneration/config.yaml \
TILE_QUEUE_SIZE=2 \
TILE_CHUNK_SIZE=1 \
TILE_SERVER_LOGLEVEL=quiet \
TILE_MAPCACHE_LOGLEVEL=verbose
TILE_MAPCACHE_LOGLEVEL=verbose \
WAITRESS_THREADS=10

EXPOSE 8080

Expand All @@ -113,10 +114,6 @@ RUN --mount=type=cache,target=/root/.cache \
&& mv docker/run /usr/bin/ \
&& python3 -m compileall -q /app/tilecloud_chain

RUN mkdir -p /prometheus-metrics \
&& chmod a+rwx /prometheus-metrics
ENV PROMETHEUS_MULTIPROC_DIR=/prometheus-metrics

# Do the lint, used by the tests
FROM base AS tests

Expand Down
34 changes: 4 additions & 30 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# TileCloud Chain
# TileCloud-chain

The goal of TileCloud Chain is to provide tools around tile generation on a chain like:

Expand Down Expand Up @@ -52,54 +52,28 @@ Only the latest release is supported and version < 1.11 contains security iss
Build it:

```bash
git submodule update --recursive
python3 -m venv .build/venv
.build/venv/bin/pip install -r requirements.txt
.build/venv/bin/pip install -e .
.build/venv/bin/pip install -r dev-requirements.txt
make build
```

## Run prospector

```bash
.build/venv/bin/prospector
make prospector
```

## Run the tests

Setup your environment:

```bash
touch tilecloud_chain/OpenLayers.js
docker build --tag camptocamp/tilecloud-chain .
docker compose -p tilecloud up
```

To run the tests:

```bash
docker compose -p tilecloud exec test python setup.py nosetests --logging-filter=tilecloud,tilecloud_chain --attr '!'nopy3
make tests
```

## Documentation

As documentation you can read the [USAGE.rst](https://github.com/camptocamp/tilecloud-chain/blob/master/tilecloud_chain/USAGE.rst)
and the [configuration reference](https://github.com/camptocamp/tilecloud-chain/blob/master/tilecloud_chain/CONFIG.md).

## VSCode

You can add that in your workspace configuration to use the JSON schema:

```json
{
"yaml.schemas": {
"../tilecloud-chain/tilecloud_chain/schema.json": [
"tilecloud-chain/tilecloud_chain/tests/tilegeneration/*.yaml"
]
}
}
```

## Contributing

Install the pre-commit hooks:
Expand Down
22 changes: 17 additions & 5 deletions development.ini → application.ini
Original file line number Diff line number Diff line change
Expand Up @@ -18,24 +18,31 @@ c2c.base_path = /c2c

tilegeneration_configfile = %(TILEGENERATION_CONFIGFILE)s

[pipeline:main]
pipeline = egg:c2cwsgiutils#client_info egg:c2cwsgiutils#sentry app
[filter:translogger]
use = egg:Paste#translogger
setup_console_handler = False

[filter:proxy-prefix]
use = egg:PasteDeploy#prefix
prefix = %(VISIBLE_ENTRY_POINT)s

[pipeline:main]
pipeline = egg:c2cwsgiutils#client_info egg:c2cwsgiutils#sentry app

[server:main]
use = egg:waitress#main
listen = *:8080
threads = %(WAITRESS_THREADS)s
trusted_proxy = True
clear_untrusted_proxy_headers = False

###
# logging configuration
# Logging configuration
# http://docs.pylonsproject.org/projects/pyramid/en/1.6-branch/narr/logging.html
###

[loggers]
keys = root, c2cwsgi, tilecloud, tilecloud_chain, sqlalchemy
keys = root, waitress, c2cwsgiutils, tilecloud, tilecloud_chain, sqlalchemy

[handlers]
keys = console, json
Expand All @@ -58,7 +65,7 @@ level = %(TILECLOUD_CHAIN_LOG_LEVEL)s
handlers =
qualname = tilecloud_chain

[logger_c2cwsgi]
[logger_c2cwsgiutils]
level = %(C2CWSGIUTILS_LOG_LEVEL)s
handlers =
qualname = c2cwsgiutils
Expand All @@ -71,6 +78,11 @@ qualname = sqlalchemy.engine
# "level = DEBUG" logs SQL queries and results.
# "level = WARN" logs neither. (Recommended for production systems.)

[logger_waitress]
level = %(WAITRESS_LOG_LEVEL)s
handlers =
qualname = waitress

[handler_console]
class = StreamHandler
args = (sys.stdout,)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
version: '2.2'

services:
application: &app
ports:
- '9050:8080'
command:
- pserve
- /venv/bin/pserve
- --reload
- c2c:///app/development.ini
- c2c:///app/application.ini
environment:
- DEVELOPMENT=TRUE
volumes:
- ./tilecloud_chain:/app/tilecloud_chain:ro
# - ../tilecloud/tilecloud:/usr/local/lib/python3.10/dist-packages/tilecloud:ro
Expand Down
2 changes: 1 addition & 1 deletion docker-compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ services:
slave:
<<: *app
command:
- generate-tiles
- /venv/bin/generate-tiles
- '--role=slave'
- '--daemon'
environment:
Expand Down
102 changes: 0 additions & 102 deletions gunicorn.conf.py

This file was deleted.

50 changes: 49 additions & 1 deletion poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 0b3e8bb

Please sign in to comment.