Added core daemon function as flags.
Created three additional flags for the hass command: -v - Toggle verbose log file output —pid-file - Specify PID file path —daemon - Launch as daemon (nix only) The core now binds to SIGQUIT on nix systems to trigger a clean shutdown. Modified HTTP server to write logging messages through the logging module.
This commit is contained in:
parent
df4afa5025
commit
ff470c8ffe
4 changed files with 119 additions and 31 deletions
|
@ -9,6 +9,7 @@ of entities and react to changes.
|
|||
import os
|
||||
import time
|
||||
import logging
|
||||
import signal
|
||||
import threading
|
||||
import enum
|
||||
import re
|
||||
|
@ -73,13 +74,16 @@ class HomeAssistant(object):
|
|||
will block until called. """
|
||||
request_shutdown = threading.Event()
|
||||
|
||||
def stop_homeassistant(service):
|
||||
def stop_homeassistant(*args):
|
||||
""" Stops Home Assistant. """
|
||||
request_shutdown.set()
|
||||
|
||||
self.services.register(
|
||||
DOMAIN, SERVICE_HOMEASSISTANT_STOP, stop_homeassistant)
|
||||
|
||||
if os.name != "nt":
|
||||
signal.signal(signal.SIGQUIT, stop_homeassistant)
|
||||
|
||||
while not request_shutdown.isSet():
|
||||
try:
|
||||
time.sleep(1)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue