mirror of
https://github.com/home-assistant/core.git
synced 2025-08-09 23:55:07 +02:00
Bugfix signhandling/services
This commit is contained in:
@@ -150,13 +150,13 @@ class HomeAssistant(object):
|
|||||||
def stop_homeassistant(*args):
|
def stop_homeassistant(*args):
|
||||||
"""Stop Home Assistant."""
|
"""Stop Home Assistant."""
|
||||||
self.exit_code = 0
|
self.exit_code = 0
|
||||||
yield from self.async_stop()
|
self.async_add_job(self.async_stop)
|
||||||
|
|
||||||
@asyncio.coroutine
|
@asyncio.coroutine
|
||||||
def restart_homeassistant(*args):
|
def restart_homeassistant(*args):
|
||||||
"""Restart Home Assistant."""
|
"""Restart Home Assistant."""
|
||||||
self.exit_code = RESTART_EXIT_CODE
|
self.exit_code = RESTART_EXIT_CODE
|
||||||
yield from self.async_stop()
|
self.async_add_job(self.async_stop)
|
||||||
|
|
||||||
# Register the restart/stop event
|
# Register the restart/stop event
|
||||||
self.loop.call_soon(
|
self.loop.call_soon(
|
||||||
@@ -169,18 +169,17 @@ class HomeAssistant(object):
|
|||||||
)
|
)
|
||||||
|
|
||||||
# Setup signal handling
|
# Setup signal handling
|
||||||
try:
|
if sys.platform != "win32":
|
||||||
signal.signal(signal.SIGTERM, stop_homeassistant)
|
self.loop.add_signal_handler(
|
||||||
except ValueError:
|
signal.SIGTERM,
|
||||||
_LOGGER.warning(
|
asyncio.async,
|
||||||
'Could not bind to SIGTERM. Are you running in a thread?')
|
stop_homeassistant()
|
||||||
try:
|
)
|
||||||
signal.signal(signal.SIGHUP, restart_homeassistant)
|
self.loop.add_signal_handler(
|
||||||
except ValueError:
|
signal.SIGHUP,
|
||||||
_LOGGER.warning(
|
asyncio.async,
|
||||||
'Could not bind to SIGHUP. Are you running in a thread?')
|
restart_homeassistant()
|
||||||
except AttributeError:
|
)
|
||||||
pass
|
|
||||||
|
|
||||||
# Run forever and catch keyboard interrupt
|
# Run forever and catch keyboard interrupt
|
||||||
try:
|
try:
|
||||||
|
Reference in New Issue
Block a user