Skip to content

About

Find all currently running Datasette instances and list their ports

Resources

Stars

4 stars

Watchers

0 watching

Forks

Latest commit

 

History

11 Commits

Folders and files

Repository files navigation

datasette-ports

PyPI Changelog Tests License

Find all currently running Datasette instances on your machine and list their ports, databases, versions and plugins.

Installation

Install this as a plugin in the same environment as Datasette.

datasette install datasette-ports

Or run it directly using uvx:

uvx datasette-ports

Or install it as a standalone tool:

uv tool install datasette-ports
datasette-ports

Usage

If installed as a Datasette plugin:

datasette ports

Or as a standalone command:

datasette-ports

This uses lsof to find all Python processes listening on TCP ports, then probes each one to check if it is a Datasette instance. For each instance found it displays the URL, Datasette version, process ID, attached databases and installed plugins.

Example output:

http://127.0.0.1:8007/ - v1.0a26 - PID: 42373
  Directory: /Users/simon/dev/blog
  Databases:
    simonwillisonblog: /Users/simon/dev/blog/simonwillisonblog.db
  Plugins:
    datasette-llm
    datasette-secrets
http://127.0.0.1:8001/ - v1.0a26 - PID: 42374
  Directory: /Users/simon/dev/creatures
  Databases:
    creatures: /tmp/creatures.db
  Plugins:
    datasette-extract
    datasette-llm
    datasette-secrets
http://127.0.0.1:8900/ - v0.65.2 - PID: 12345
  Databases:
    logs: /Users/simon/Library/Application Support/io.datasette.llm/logs.db
http://0.0.0.0:8014/ - v1.0a26 - PID: 42375
  Directory: /Users/simon/dev/datasette
  Databases:
    content: /Users/simon/dev/datasette/content.db
    trees: /Users/simon/dev/datasette/trees.db
    _internal
  Plugins:
    datasette-llm
    datasette-visible-internal-db

Database paths come from each instance's /-/databases.json endpoint. Where the process working directory can be determined (via /proc/<pid>/cwd on Linux or lsof on macOS), relative paths are resolved to absolute ones. On platforms where the working directory cannot be determined the Directory: line is omitted and paths are shown as reported by Datasette.

JSON output

Use --json to get machine-readable output:

datasette ports --json
# or
datasette-ports --json
[
  {
    "url": "http://127.0.0.1:8007/",
    "host": "127.0.0.1",
    "port": 8007,
    "pid": 42373,
    "cwd": "/Users/simon/dev/blog",
    "version": "1.0a26",
    "databases": [
      {"name": "simonwillisonblog", "path": "/Users/simon/dev/blog/simonwillisonblog.db"}
    ],
    "plugins": [
      "datasette-llm",
      "datasette-secrets"
    ]
  },
  {
    "url": "http://127.0.0.1:8900/",
    "host": "127.0.0.1",
    "port": 8900,
    "pid": 12345,
    "cwd": null,
    "version": "0.65.2",
    "databases": [
      {"name": "logs", "path": "/Users/simon/Library/Application Support/io.datasette.llm/logs.db"}
    ],
    "plugins": []
  }
]

Development

To set up this project locally, first checkout the code. You can confirm it is available like this:

cd datasette-ports
uv run datasette-ports --help
# Or:
uv run datasette ports --help

To run the tests:

uv run pytest

About

Find all currently running Datasette instances and list their ports

Resources

Stars

4 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages