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.2.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 88ddbfc44593ff10fe4c660eba741573ed4a5025a981d1fa708191d06eb2a335 |
|
MD5 | af87c614d18012104cabac393b51be2a |
|
BLAKE2b-256 | 42f83c0bf0d5b25d11821b7c4178e788a39faf4f28b5ec44c18743f8d3c1f123 |
Hashes for datasette_scale_to_zero-0.1.2-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 7af991dc7b3dd3bee2340307ebde614f0b7317e2d8034ad6800a6ada4bee7186 |
|
MD5 | 93fcf03d891dd0a5f320fca52e8c5659 |
|
BLAKE2b-256 | 8560cab29199300cc485a3faf94e41919e4730f6463b9246e7698ba0b5f4cae2 |