machine: add "restart_service" method
Move the service restart functionality out of the "service restart" request into its own method. This allows the "service restart" to be called internally by other modules. Signed-off-by: Eric Callahan <arksine.code@gmail.com>
This commit is contained in:
parent
aa9bf0fb9c
commit
c365de32cf
|
@ -39,13 +39,15 @@ class Machine:
|
||||||
async def reboot_machine(self):
|
async def reboot_machine(self):
|
||||||
await self._execute_cmd("sudo shutdown -r now")
|
await self._execute_cmd("sudo shutdown -r now")
|
||||||
|
|
||||||
|
async def restart_service(self, service_name):
|
||||||
|
await self._execute_cmd(f'sudo systemctl restart {service_name}')
|
||||||
|
|
||||||
async def _handle_service_restart(self, web_request):
|
async def _handle_service_restart(self, web_request):
|
||||||
name = web_request.get('service')
|
name = web_request.get('service')
|
||||||
if name == "klipper":
|
if name == "klipper":
|
||||||
await self._execute_cmd(f'sudo systemctl restart {name}')
|
await self.restart_service(name)
|
||||||
elif name == "moonraker":
|
elif name == "moonraker":
|
||||||
IOLoop.current().spawn_callback(
|
IOLoop.current().spawn_callback(self.restart_service, name)
|
||||||
self._execute_cmd, f'sudo systemctl restart {name}')
|
|
||||||
else:
|
else:
|
||||||
raise self.sever.error(
|
raise self.sever.error(
|
||||||
f"Invalid argument recevied for 'name': {name}")
|
f"Invalid argument recevied for 'name': {name}")
|
||||||
|
|
Loading…
Reference in New Issue