forked from retoor/devplacepy
Code Farm: per-plot auto-replant pause and crop-lock check; community sync and node work
Continuous Delivery could never be turned off once a crop was planted. Add a one-shot per-plot "stop after harvest" flag (POST /game/plot/stop, Devii tool game_plot_stop, game_plots.stop_after_harvest), cleared by the next plant, autoreplant claim or Refactor. Autoreplant now also respects crop locks through the shared _crop_lock predicate. Plan and measurements in happyplanting.md. Also includes the pending community sync, node network and related work in the tree; the full suite passed (4999) with all of it. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,38 @@
|
||||
# retoor <retoor@molodetz.nl>
|
||||
|
||||
import asyncio
|
||||
|
||||
from fastapi import FastAPI
|
||||
|
||||
|
||||
def build() -> FastAPI:
|
||||
from devplacepy.database import init_db, refresh_snapshot, set_setting
|
||||
from devplacepy.routers.nodes import router
|
||||
from devplacepy.services.manager import service_manager
|
||||
from devplacepy.services.nodes.service import NodesService
|
||||
|
||||
app = FastAPI()
|
||||
app.include_router(router, prefix="/nodes")
|
||||
service = NodesService()
|
||||
|
||||
@app.on_event("startup")
|
||||
async def start() -> None:
|
||||
init_db()
|
||||
set_setting("nodes_enabled", "1")
|
||||
set_setting("nodes_allow_unknown_class", "1")
|
||||
service_manager.register(service)
|
||||
service_manager.set_lock_owner(True)
|
||||
service_manager.supervise()
|
||||
service.scheduler.destination_ready = lambda target: True
|
||||
await asyncio.sleep(0)
|
||||
|
||||
@app.middleware("http")
|
||||
async def fresh_snapshot(request, call_next):
|
||||
refresh_snapshot()
|
||||
return await call_next(request)
|
||||
|
||||
@app.get("/stats")
|
||||
async def stats() -> dict:
|
||||
return {"connected": service.registry.count(), "counters": service.counters.snapshot()}
|
||||
|
||||
return app
|
||||
Reference in New Issue
Block a user