Skip to content

Commit 5881171

Browse files
committed
Update readme
1 parent 6177660 commit 5881171

1 file changed

Lines changed: 33 additions & 2 deletions

File tree

README.md

Lines changed: 33 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@ Options:
162162
human-readable duration) an idle blocking
163163
thread will be kept alive [env var:
164164
GRANIAN_BLOCKING_THREADS_IDLE_TIMEOUT;
165-
default: 30; 10<=x<=600]
165+
default: 30; 5<=x<=600]
166166
--runtime-threads INTEGER RANGE
167167
Number of runtime threads (per worker) [env
168168
var: GRANIAN_RUNTIME_THREADS; default: 1;
@@ -460,9 +460,11 @@ Given you specify N threads with the relevant option, in **st** mode Granian wil
460460

461461
Benchmarks suggests **st** mode to be more efficient with a small amount of processes, while **mt** mode seems to scale more efficiently where you have a large number of CPUs. Real performance will though depend on specific application code, and thus *your mileage might vary*.
462462

463+
By default (**auto** mode), Granian will pick the best option based on the rest of its configuration.
464+
463465
### Metrics
464466

465-
Granian exposes the following runtime metrics in Prometheus format. All the metrics are prefixed with `granian_`, and ones marked with *worker* scope are tagged with a `worker` label containing the worker ID.
467+
Granian exposes the following runtime metrics in Prometheus format. All the metrics are prefixed with `granian_`, and the ones marked with *worker* scope are tagged with a `worker` label containing the worker ID.
466468

467469
| metric name | type | unit | scope | description |
468470
| --- | --- | --- | --- | --- |
@@ -484,6 +486,35 @@ Granian exposes the following runtime metrics in Prometheus format. All the metr
484486
| `blocking_busy_cumulative` | counter | microseconds | worker | Cumulative busy time spent in the blocking threadpool |
485487
| `py_wait_cumulative` | counter | microseconds | worker | Cumulative time spent waiting on GIL (on the free-threaded build this is always 0) |
486488

489+
### Static files
490+
491+
Granian offers the ability to *offload* static files serving directly to the server, without calling your Python application in the process.
492+
493+
The `--static-path-route` and `--static-path-mount` options accept multiple values, thus you can serve an arbitrary number of static *locations* in your application, the only condition being the number of routes and mounts specified should be the same:
494+
495+
```
496+
$ granian \
497+
--static-path-route /static \
498+
--static-path-mount assets/static \
499+
--static-path-route /media \
500+
--static-path-mount assets/media \
501+
package:app
502+
```
503+
504+
#### Serving a specific file for directory listings
505+
506+
Granian also provides the option to *rewrite* a static location pointing to a directory to a file contained in such directory. This allows you to serve, for example, an `index.html` file in the static path tree:
507+
508+
```
509+
$ granian \
510+
--static-path-route /docs \
511+
--static-path-mount generated/docs \
512+
--static-path-dir-to-file index.html \
513+
package:app
514+
```
515+
516+
> **Note:** while Granian performs a rewrite on the target directory, the file will still be served if the request path points to it directly (in the example above, requests pointing to `/docs/somefolder` and `/docs/somefolder/index.html` will both respond with the contents of `index.html` – if present). Also, the option will enable this behavior on all the static paths defined.
517+
487518
### Proxies and forwarded headers
488519

489520
Since none of the supported applications protocols define a strategy for proxies' *forwarded headers*, Granian doesn't provide any option to configure its behaviour around them.

0 commit comments

Comments
 (0)