datasette-scale-to-zero
Quit Datasette if it has not received traffic for a specified time period
Some hosting providers such as Fly offer a scale to zero mechanism, where servers can shut down and will be automatically started when new traffic arrives.
This plugin can be used to configure Datasette to quit X minutes (or seconds, or hours) after the last request it received. It can also cause the Datasette server to exit after a configured maximum time whether or not it is receiving traffic.
Installation
Install this plugin in the same environment as Datasette.
datasette install datasette-scale-to-zero
Configuration
This plugin will only take effect if it has been configured with a duration or max_age value. Without at least one of these settings the plugin will do nothing.
Add the following to your metadata.json or metadata.yml configuration file:
{
"plugins": {
"datasette-scale-to-zero": {
"duration": "10m"
}
}
}
This will cause Datasette to quit if it has not received any HTTP traffic for 10 minutes.
You can set this value using a suffix of m for minutes, h for hours or s for seconds.
To cause Datasette to exit if the server has been running for longer than a specific time, use "max_age":
{
"plugins": {
"datasette-scale-to-zero": {
"max_age": "10h"
}
}
}
This example will exit the Datasette server if it has been running for more than ten hours.
You can use "duration" and "max_age" together in the same configuration file:
{
"plugins": {
"datasette-scale-to-zero": {
"max_age": "10h",
"duration": "5m"
}
}
}
This example will quit if no traffic has been received in five minutes, or if the server has been running for ten hours.
Configuring a shutdown HTTP message
You can also configure the plugin to send an HTTP request somewhere right before it quits, using the "shutdown_url" option:
{
"plugins": {
"datasette-scale-to-zero": {
"duration": "10m",
"shutdown_url": "https://example.com/shutdown"
}
}
}
You can add additional headers to the GET request - for example to send Authorization headers - using "shutdown_headers":
{
"plugins": {
"datasette-scale-to-zero": {
"duration": "10m",
"shutdown_url": "https://example.com/shutdown",
"shutdown_headers": {
"Authorization": "Bearer secret"
}
}
}
}
Use "shutdown_method" to set a different HTTP method, e.g. for POST. You can also set shutdown_body to specify the body that should be sent with the request:
{
"plugins": {
"datasette-scale-to-zero": {
"duration": "10m",
"shutdown_url": "https://example.com/shutdown",
"shutdown_method": "POST",
"shutdown_headers": {
"Authorization": "Bearer secret",
"Content-Type": "application/json"
},
"shutdown_body": "{\"message\": \"shutting down\"}"
}
}
}
Development
To set up this plugin locally, first checkout the code. Then create a new virtual environment:
cd datasette-scale-to-zero
python3 -m venv venv
source venv/bin/activate
Now install the dependencies and test dependencies:
pip install -e '.[test]'
To run the tests:
pytest
Metadata
Release files for datasette-scale-to-zero 0.3.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| datasette_scale_to_zero-0.3.2.tar.gz | 3.8 kB | With provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| datasette_scale_to_zero-0.3.2-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 8.6 kB
Release files / datasette_scale_to_zero-0.3.2.tar.gz
| Download URL | datasette_scale_to_zero-0.3.2.tar.gz |
|---|---|
| Size | 3.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
457d97d389df85b5e5666d050f1f102cdeaa61714d781db82d0287519fd26736
|
|
BLAKE2b-256 checksum How to use checksums |
d445b8d59d4f4b9ed9fd5337bda954fcac65647eeca3cda6610a7180526f4220
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.7
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Jan 19, 2026.
Transparency logRelease files / datasette_scale_to_zero-0.3.2-py3-none-any.whl
| Download URL | datasette_scale_to_zero-0.3.2-py3-none-any.whl |
|---|---|
| Size | 4.8 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
c2da2f3c63323c127685bd43450b626615e156331322893aa9eb2779bd4ff952
|
|
BLAKE2b-256 checksum How to use checksums |
7b3ab03af90f15f0d8efad8c18746b2ef410f806a1b81035238b3fe66333cbd5
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.7
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Jan 19, 2026.
Transparency logSecurity for datasette-scale-to-zero 0.3.2
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
Full provenance
All 2 files in this release have been uploaded with provenance metadata.
Attestation for datasette_scale_to_zero-0.3.2.tar.gz
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Jan 19, 2026.
Transparency logA note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.