跳转到主要内容

使用Gunicorn运行Datasette服务器

项目描述

datasette-gunicorn

PyPI Changelog Tests License

使用DatasetteGunicorn运行服务器

安装

在Datasette相同的环境中安装此插件。

datasette install datasette-gunicorn

用法

此插件添加了一个新的datasette gunicorn命令。它接受与datasette serve大多数相同的选项,还有一个用于设置要启动的Gunicorn工作进程数的选项。

-w/--workers X - 设置工作进程数。默认为1。

要使用4个工作进程开始提供数据库服务,请运行以下命令

datasette gunicorn fixtures.db -w 4

建议将您的datasette切换到WAL模式,以从此配置中获得最佳性能

sqlite3 fixtures.db 'PRAGMA journal_mode=WAL;'

运行datasette gunicorn --help以获取选项的完整列表(与datasette serve --help相同,新增了-w选项)。

datasette gunicorn --help

并非所有datasette serve的选项都受支持。以下是完整选项列表

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.

开发

要本地设置此插件,首先检出代码。然后创建一个新的虚拟环境

cd datasette-gunicorn
python3 -m venv venv
source venv/bin/activate

现在安装依赖项和测试依赖项

pip install -e '.[test]'

要运行测试

pytest

项目详情


下载文件

下载适用于您平台的文件。如果您不确定选择哪个,请了解更多关于安装包的信息。

源分布

datasette-gunicorn-0.1.1.tar.gz (8.1 kB 查看哈希值)

上传时间 来源

构建分布版

datasette_gunicorn-0.1.1-py3-none-any.whl (8.6 kB 查看哈希值)

上传时间 Python 3

支持者