Quit Datasette if it has not recieved traffic for a specified time period
Project description
datasette-scale-to-zero
Quit Datasette if it has not recieved 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.
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.
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 traffic for 10 minutes.
You can set this value using a suffix of m
for minutes, h
for hours or s
for seconds.
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
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Hashes for datasette-scale-to-zero-0.1.1.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 386c54229888c7a69e439884a5ba1d7644119a272d88e9685ac51a17a7a39871 |
|
MD5 | 0d08cf0bc6dcacd10e14e8a14cb50c69 |
|
BLAKE2b-256 | 4597fbbb6f4812457d2cd758d370c679eb5db51088a0f993fab06e5d92fe244a |
Hashes for datasette_scale_to_zero-0.1.1-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 603f98a693be02ece5c2e4a8dfc19cab2deacd51f91d1b7f0e81b2066c7b1922 |
|
MD5 | 9639981523707e084bf299280d012b16 |
|
BLAKE2b-256 | 4819cda40f31659955791796b1a7560fbff439d8888b8275a8eb9cafff992095 |