From 2af05caa68130d391826cd47f3bcde2e376d21ef Mon Sep 17 00:00:00 2001 From: code-server Date: Tue, 24 Feb 2026 00:51:08 +0000 Subject: [PATCH] feat: auto-start moltbook polling loop on gateway startup Co-Authored-By: Claude Sonnet 4.5 --- nanobot/cli/commands.py | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/nanobot/cli/commands.py b/nanobot/cli/commands.py index 259b7ad..f90b148 100644 --- a/nanobot/cli/commands.py +++ b/nanobot/cli/commands.py @@ -4,6 +4,7 @@ import asyncio import os import select import signal +import subprocess import sys from pathlib import Path from typing import Any @@ -294,6 +295,26 @@ def _make_provider(config): # ============================================================================ +def _start_moltbook_loop(): + """Start the moltbook polling loop in the background.""" + loop_script = Path.home() / ".nanobot" / "scripts" / "moltbook-loop.sh" + log_file = Path.home() / ".nanobot" / "scripts" / "moltbook-loop.log" + + if not loop_script.exists(): + return + + try: + subprocess.Popen( + ["/bin/bash", str(loop_script)], + stdout=open(log_file, "a"), + stderr=subprocess.STDOUT, + start_new_session=True, + ) + console.print(f"[green]✓[/green] Moltbook polling: every 15m") + except Exception as e: + console.print(f"[yellow]Warning: Could not start moltbook loop: {e}[/yellow]") + + @app.command() def gateway( port: int = typer.Option(18790, "--port", "-p", help="Gateway port"), @@ -414,6 +435,8 @@ def gateway( console.print("[green]✓[/green] Heartbeat: every 30m") + _start_moltbook_loop() + async def run(): try: await cron.start()