mirror of
https://github.com/lrnselfreliance/wrolpi.git
synced 2026-12-02 20:59:56 -05:00
Delaying reboot/shutdown with asyncio sleep to give API time to shut down.
This commit is contained in:
parent
5ffb8bee8d
commit
4cc00a9cb1
9 changed files with 71 additions and 49 deletions
|
|
@ -25,7 +25,7 @@ from wrolpi.common import logger, get_config, wrol_mode_enabled, Base, get_media
|
|||
from wrolpi.dates import now, strptime
|
||||
from wrolpi.downloader import download_manager
|
||||
from wrolpi.errors import WROLModeEnabled, APIError, HotspotError, InvalidDownload, \
|
||||
HotspotPasswordTooShort, ShutdownFailed, RestartFailed
|
||||
HotspotPasswordTooShort, NativeOnly
|
||||
from wrolpi.events import get_events, Events
|
||||
from wrolpi.files.lib import get_file_statistics, estimate_search
|
||||
from wrolpi.vars import API_HOST, API_PORT, DOCKERIZED, API_DEBUG, API_ACCESS_LOG, API_WORKERS, API_AUTO_RELOAD, \
|
||||
|
|
@ -504,16 +504,16 @@ async def post_search_estimate(_: Request, body: schema.SearchEstimateRequest):
|
|||
@api_bp.post('/restart')
|
||||
async def post_restart(_: Request):
|
||||
if DOCKERIZED:
|
||||
raise RestartFailed(f'Cannot restart when running in Docker')
|
||||
raise NativeOnly(f'Cannot restart when running in Docker')
|
||||
|
||||
await admin.restart()
|
||||
await admin.shutdown(reboot=True)
|
||||
return response.empty(HTTPStatus.NO_CONTENT)
|
||||
|
||||
|
||||
@api_bp.post('/shutdown')
|
||||
async def post_shutdown(_: Request):
|
||||
if DOCKERIZED:
|
||||
raise ShutdownFailed(f'Cannot shutdown when running in Docker')
|
||||
raise NativeOnly(f'Cannot shutdown when running in Docker')
|
||||
|
||||
await admin.shutdown()
|
||||
return response.empty(HTTPStatus.NO_CONTENT)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue