Skip to main content

Run a Datasette server using Gunicorn

Project description

datasette-gunicorn

PyPI Changelog Tests License

Run a Datasette server using Gunicorn

Installation

Install this plugin in the same environment as Datasette.

datasette install datasette-gunicorn

Usage

The plugin adds a new datasette gunicorn command. This takes most of the same options as datasette serve, plus one more option for setting the number of Gunicorn workers to start:

-w/--workers X - set the number of workers. Defaults to 1.

To start serving a database using 4 workers, run the following:

datasette gunicorn fixtures.db -w 4

It is advisable to switch your datasette into WAL mode to get the best performance out of this configuration:

sqlite3 fixtures.db 'PRAGMA journal_mode=WAL;'

Run datasette gunicorn --help for a full list of options (which are the same as datasette serve --help, with the addition of the new -w option).

datasette gunicorn --help

Not all of the options to datasette serve are supported. Here's the full list of available options:

Usage: datasette gunicorn [OPTIONS] [FILES]...

  Start a Gunicorn server running to serve Datasette

Options:
  -i, --immutable PATH      Database files to open in immutable mode
  -h, --host TEXT           Host for server. Defaults to 127.0.0.1 which means
                            only connections from the local machine will be
                            allowed. Use 0.0.0.0 to listen to all IPs and allow
                            access from other machines.
  -p, --port INTEGER RANGE  Port for server, defaults to 8001. Use -p 0 to
                            automatically assign an available port.
                            [0<=x<=65535]
  --cors                    Enable CORS by serving Access-Control-Allow-Origin:
                            *
  --load-extension TEXT     Path to a SQLite extension to load
  --inspect-file TEXT       Path to JSON file created using "datasette inspect"
  -m, --metadata FILENAME   Path to JSON/YAML file containing license/source
                            metadata
  --template-dir DIRECTORY  Path to directory containing custom templates
  --plugins-dir DIRECTORY   Path to directory containing custom plugins
  --static MOUNT:DIRECTORY  Serve static files from this directory at /MOUNT/...
  --memory                  Make /_memory database available
  --config CONFIG           Deprecated: set config option using
                            configname:value. Use --setting instead.
  --setting SETTING...      Setting, see
                            docs.datasette.io/en/stable/settings.html
  --secret TEXT             Secret used for signing secure values, such as
                            signed cookies
  --version-note TEXT       Additional note to show on /-/versions
  --help-settings           Show available settings
  --create                  Create database files if they do not exist
  --crossdb                 Enable cross-database joins using the /_memory
                            database
  --nolock                  Ignore locking, open locked files in read-only mode
  -w, --workers INTEGER     Number of Gunicorn workers  [default: 1]
  --help                    Show this message and exit.

Development

To set up this plugin locally, first checkout the code. Then create a new virtual environment:

cd datasette-gunicorn
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

datasette-gunicorn-0.1.tar.gz (8.1 kB view details)

Uploaded Source

Built Distribution

datasette_gunicorn-0.1-py3-none-any.whl (8.6 kB view details)

Uploaded Python 3

File details

Details for the file datasette-gunicorn-0.1.tar.gz.

File metadata

  • Download URL: datasette-gunicorn-0.1.tar.gz
  • Upload date:
  • Size: 8.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.10.8

File hashes

Hashes for datasette-gunicorn-0.1.tar.gz
Algorithm Hash digest
SHA256 10fc28f690f2e4b7e16f2e5af8b70dfda252757459c7f243c8863803c7dfb6c7
MD5 1dc1abb8d703a34a8a7601a3c1d6881f
BLAKE2b-256 c4a069c0fcf216e61fa49f27f793f7e5f70c05ba2cd26c627603548364102ed1

See more details on using hashes here.

File details

Details for the file datasette_gunicorn-0.1-py3-none-any.whl.

File metadata

File hashes

Hashes for datasette_gunicorn-0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 6946c7f3abb0168334440bc91bde15786e056e1cd8083ddd3e4f0c6f6cb8e539
MD5 c07f3e3ef0d4497c7e3624d7df3c49c4
BLAKE2b-256 da4b7ef55037a25f9ab9f944bd9031c974d435797ca61660cc56d24abbb1a29d

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page