Orchestrator for mrmd services - starts sync, monitors, and runtimes
Project description
mrmd-orchestrator
Python orchestrator for mrmd services. Starts and manages sync server, monitors, and runtimes.
Quick Start
# From mrmd-packages directory
cd mrmd-orchestrator
# Create virtual environment and install dependencies with uv
uv venv
uv pip install -e .
# Start everything
uv run mrmd
# Or with options
uv run mrmd --docs ./notebooks --port 3000
Then open http://localhost:8080/examples/minimal.html
What It Does
The orchestrator:
- Starts mrmd-sync - Yjs sync server on ws://localhost:4444
- Starts mrmd-python - Python runtime on http://localhost:8000
- Serves mrmd-editor - Static files on http://localhost:8080
- Manages monitors - Start/stop via HTTP API
┌─────────────────────────────────────────────────────────────────┐
│ mrmd-orchestrator (Python) │
│ │
│ ┌─────────────┐ ┌─────────────┐ ┌─────────────┐ │
│ │ mrmd-sync │ │ mrmd-python │ │ HTTP Server │ │
│ │ (Node.js) │ │ (Python) │ │ + API │ │
│ │ port 4444 │ │ port 8000 │ │ port 8080 │ │
│ └─────────────┘ └─────────────┘ └─────────────┘ │
│ │ │ │
│ └──── monitors (per document) ──────┘ │
│ ┌─────────┐ ┌─────────┐ │
│ │monitor:a│ │monitor:b│ ... │
│ └─────────┘ └─────────┘ │
└─────────────────────────────────────────────────────────────────┘
CLI Options
mrmd [options]
Paths:
--docs, -d PATH Document directory (default: ./docs)
--packages PATH Path to mrmd-packages (auto-detected)
Ports:
--port, -p PORT HTTP/API port (default: 8080)
--sync-port PORT Sync server port (default: 4444)
--runtime-port PORT Python runtime port (default: 8000)
Remote Services (distributed mode):
--sync-url URL Connect to existing sync server
--runtime-url URL Connect to existing runtime
Disable Services:
--no-sync Don't start mrmd-sync
--no-runtime Don't start mrmd-python
--no-editor Don't serve editor files
--no-monitors Don't allow starting monitors
Auto-start:
--monitor DOC Auto-start monitor for document (repeatable)
Examples:
mrmd # Start everything
mrmd --docs ./notebooks # Custom docs directory
mrmd --monitor my-notebook # Auto-start monitor
mrmd --sync-url ws://remote:4444 # Use remote sync
HTTP API
Status
# Health check
GET /health
# Full status
GET /api/status
# Service URLs
GET /api/urls
Monitors
# List active monitors
GET /api/monitors
# Start monitor for document
POST /api/monitors
Content-Type: application/json
{"doc": "my-notebook"}
# Stop monitor
DELETE /api/monitors/my-notebook
# Check monitor status
GET /api/monitors/my-notebook
Logs
# Get recent output from a process
GET /api/logs/mrmd-sync?lines=100
GET /api/logs/mrmd-python?lines=50
GET /api/logs/monitor:my-notebook?lines=50
Distributed Mode
For users who want services on different machines:
# Machine 1: Sync server only
cd mrmd-sync && node bin/cli.js ./docs
# Machine 2: Python runtime only
cd mrmd-python && python -m mrmd_python.cli --port 8000
# Machine 3: Orchestrator connecting to remote services
mrmd \
--sync-url ws://machine1:4444 \
--runtime-url http://machine2:8000/mrp/v1 \
--no-sync \
--no-runtime
Or use the Python API:
from mrmd_orchestrator import Orchestrator, OrchestratorConfig
config = OrchestratorConfig.for_distributed(
sync_url="ws://remote-sync:4444",
runtime_urls={"python": "http://remote-python:8000/mrp/v1"},
)
orchestrator = Orchestrator(config)
await orchestrator.start()
Programmatic Usage
import asyncio
from mrmd_orchestrator import Orchestrator, OrchestratorConfig
async def main():
# Default config (start everything locally)
config = OrchestratorConfig.for_development()
# Create orchestrator
orchestrator = Orchestrator(config)
# Start services
await orchestrator.start()
# Start a monitor
await orchestrator.start_monitor("my-notebook")
# Check status
status = orchestrator.get_status()
print(status)
# Stop monitor
await orchestrator.stop_monitor("my-notebook")
# Stop everything
await orchestrator.stop()
asyncio.run(main())
Architecture: 1 Monitor Per Document
Each document gets its own monitor process:
Document A ──→ monitor:document-a ──→ mrmd-python (session: document-a)
Document B ──→ monitor:document-b ──→ mrmd-python (session: document-b)
Why?
- Isolation: Killing notebook A doesn't affect B
- Matches mental model: "Restart" means this notebook
- Security: Different permissions per notebook
- Matches Jupyter: 1 kernel per notebook
Trade-offs:
- More processes (10 notebooks = 10 monitors)
- Startup latency when opening new documents
Development
# Create venv and install with dev dependencies
cd mrmd-orchestrator
uv venv
uv pip install -e ".[dev]"
# Run tests
uv run pytest
# Run with debug logging
uv run mrmd --log-level debug
License
MIT
Project details
Release history Release notifications | RSS feed
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
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file mrmd_orchestrator-0.1.0.tar.gz.
File metadata
- Download URL: mrmd_orchestrator-0.1.0.tar.gz
- Upload date:
- Size: 100.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.7.4
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e60558c189374eb4dc3ed1a08d67d8ba81dfc52e151ab223297950c6e9091adf
|
|
| MD5 |
170df84c3c342ea403d02d2f94120262
|
|
| BLAKE2b-256 |
18007b05777e95374eea2e42aa38af99a74ec8923c9960a92d3996a2fb97fcec
|
File details
Details for the file mrmd_orchestrator-0.1.0-py3-none-any.whl.
File metadata
- Download URL: mrmd_orchestrator-0.1.0-py3-none-any.whl
- Upload date:
- Size: 22.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.7.4
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a57b1b95b6c255a98ddf6f6c16fa59f67e9f29d16c3f1dd947f4d608cd176c60
|
|
| MD5 |
1e8a5bc4184aa40e025a867c55d5f282
|
|
| BLAKE2b-256 |
01c062c905915d6bb7c0c73566c85122fd6f9a0f9c4edf6bd5e7e3de8995cb48
|