Bugfix signhandling/services

This commit is contained in:
pvizeli
2016-10-04 12:29:38 +02:00
parent 2cf49f3de6
commit f57e1fe336

View File

@@ -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: