Skip to main content

datasette-scale-to-zero

PyPI Changelog Tests License

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.

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.

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

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

datasette-scale-to-zero-0.2.tar.gz (7.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

datasette_scale_to_zero-0.2-py3-none-any.whl (7.9 kB view details)

Uploaded Python 3

File details

Details for the file datasette-scale-to-zero-0.2.tar.gz.

File metadata

  • Download URL: datasette-scale-to-zero-0.2.tar.gz
  • Upload date:
  • Size: 7.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.10.5

File hashes

Hashes for datasette-scale-to-zero-0.2.tar.gz
Algorithm Hash digest
SHA256 b6b982885612bf3654d87ddcdf123497c90892c8b84ee30a9e7424b7d8c09fd1
MD5 a7fd753b1b06a4eff9644f953b43b499
BLAKE2b-256 02fbb84a86f8cc0a7b3ddf3648e54c3b6fa070c279f27f947e84b9f25f14a4df

See more details on using hashes here.

File details

Details for the file datasette_scale_to_zero-0.2-py3-none-any.whl.

File metadata

File hashes

Hashes for datasette_scale_to_zero-0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 9e111a36754d5e109be5eaae0565520fb8f98414774213ba557955f4116f98d5
MD5 acbf66f6958d9e029017a059ca7c26b0
BLAKE2b-256 701f52e45cbd6840f8e28d8b369b114c252d9fe8a37caa2ba21b75d5d13771fb

See more details on using hashes here.

Release history Release notifications | RSS feed

0.3.2

2 files

0.3.1

2 files

0.3

2 files

This release

0.2 This release

2 files

0.1.2

2 files

0.1.1

2 files

0.1

2 files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page