Changed ProcessController to handle Server as child subprocess

This commit is contained in:
Malasaur 2025-12-01 22:43:15 +01:00
parent 9742cafad9
commit a008bc27fa
No known key found for this signature in database
5 changed files with 52 additions and 53 deletions

View file

@ -3,6 +3,8 @@ from typing import Callable
from fastapi import HTTPException
from minecraftd.classes import ProcessStatus
from .config import Config
from .controllers import Controllers
@ -28,12 +30,12 @@ async def stop_server(
await sleep(1)
countdown -= 1
# Controllers.server.command("stop")
while timeout > 0 and Controllers.process.is_started():
Controllers.server.command("stop")
while timeout > 0 and Controllers.process.status() == ProcessStatus.RUNNING:
await sleep(1)
timeout -= 1
if Controllers.process.is_started():
if Controllers.process.status() == ProcessStatus.RUNNING:
Controllers.process.kill()
if then: