mirror of
https://github.com/firestar5683/StarPilot.git
synced 2026-10-01 03:43:46 +08:00
Move shutdown/reboot handling to manager (#22882)
* Move shutdown/reboot handling to manager * more logging * check enagaged * Apply suggestions from code review Co-authored-by: Adeeb Shihadeh <adeebshihadeh@gmail.com> old-commit-hash: 07ff72472636237d7c47addfce4d8bbbda98e9d2
This commit is contained in:
@@ -158,9 +158,14 @@ def manager_thread():
|
||||
msg.managerState.processes = [p.get_process_state_msg() for p in managed_processes.values()]
|
||||
pm.send('managerState', msg)
|
||||
|
||||
# TODO: let UI handle this
|
||||
# Exit main loop when uninstall is needed
|
||||
if params.get_bool("DoUninstall"):
|
||||
# Exit main loop when uninstall/shutdown/reboot is needed
|
||||
shutdown = False
|
||||
for param in ("DoUninstall", "DoShutdown", "DoReboot"):
|
||||
if params.get_bool(param):
|
||||
cloudlog.warning(f"Shutting down manager - {param} set")
|
||||
shutdown = True
|
||||
|
||||
if shutdown:
|
||||
break
|
||||
|
||||
|
||||
@@ -189,9 +194,16 @@ def main():
|
||||
finally:
|
||||
manager_cleanup()
|
||||
|
||||
if Params().get_bool("DoUninstall"):
|
||||
params = Params()
|
||||
if params.get_bool("DoUninstall"):
|
||||
cloudlog.warning("uninstalling")
|
||||
HARDWARE.uninstall()
|
||||
elif params.get_bool("DoReboot"):
|
||||
cloudlog.warning("reboot")
|
||||
HARDWARE.reboot()
|
||||
elif params.get_bool("DoShutdown"):
|
||||
cloudlog.warning("shutdown")
|
||||
HARDWARE.shutdown()
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
||||
Reference in New Issue
Block a user