Changed ProcessController to handle Server as child subprocess
This commit is contained in:
parent
9742cafad9
commit
a008bc27fa
5 changed files with 52 additions and 53 deletions
8
util.py
8
util.py
|
|
@ -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:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue