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.
To configur, 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.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 207324a1ddce1ce7da5f7a5d6783cc42950efcaa46fa0e0011703559f6db6769 |
|
MD5 | 533c2931de26bd67e75003fbea543020 |
|
BLAKE2b-256 | 462cc56cf16bdd6dd44cf1e06f1dd9ec2b7b1a3ae8e3086a1c56c72dd998bd8f |
Hashes for datasette_scale_to_zero-0.1-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 159da4211471b19ed31128720b4a974a3300d84e1e5f07c2879baf001dfb1971 |
|
MD5 | b533067e254209c3d43aa915ef7788e3 |
|
BLAKE2b-256 | 82d8b479f78b3614d21a38c8953f31dcf6f6ff55a23755046460bd015a4aead6 |