This commit is contained in:
2026-01-23 16:46:48 -08:00
parent 797b5fee40
commit b3a4ba14e5
5 changed files with 193 additions and 106 deletions

48
CLI.py
View File

@@ -32,7 +32,6 @@ if not os.environ.get("MM_DEBUG"):
pass
import json
import re
import shlex
import sys
import threading
@@ -395,7 +394,7 @@ class CmdletCompleter(Completer):
for idx, tok in enumerate(tokens):
low = str(tok or "").strip().lower()
if "=" in low:
head, val = low.split("=", 1)
head, _ = low.split("=", 1)
if head in want:
return tok.split("=", 1)[1]
if low in want and idx + 1 < len(tokens):
@@ -1482,51 +1481,6 @@ class CLI:
def repl() -> None:
self.run_repl()
@app.command("remote-server")
def remote_server(
storage_path: str = typer.Argument(
None, help="Path to the storage root"
),
port: int = typer.Option(None, "--port", help="Port to run the server on"),
api_key: str | None = typer.Option(None, "--api-key", help="API key for authentication"),
host: str = "0.0.0.0",
debug_server: bool = False,
background: bool = False,
) -> None:
"""Start the remote storage server.
NOTE: The legacy local storage server has been removed. Use HydrusNetwork
integrations instead.
"""
print(
"Error: remote-server is no longer available because legacy local storage has been removed.",
file=sys.stderr,
)
return
print(
f"Starting remote storage server at http://{host}:{port}, storage: {storage}"
)
if background:
try:
from werkzeug.serving import make_server
import threading
server = make_server(host, port, app_obj)
thread = threading.Thread(target=server.serve_forever, daemon=True)
thread.start()
print(f"Server started in background (thread id={thread.ident})")
return
except Exception as exc:
print("Failed to start background server, falling back to foreground:", exc, file=sys.stderr)
# Foreground run blocks the CLI until server exits
try:
app_obj.run(host=host, port=port, debug=debug_server, use_reloader=False, threaded=True)
except KeyboardInterrupt:
print("Remote server stopped by user")
@app.callback(invoke_without_command=True)
def main_callback(ctx: typer.Context) -> None:
if ctx.invoked_subcommand is None: