lib.daemon

This file contains the functions needed to run SmartHomeNG as a deamon

lib.daemon.check_sh_is_running(pidfile)[source]

This method checks whether another smarthome process process is already running.

Parameters:pidfile (str) – Name of the pidfile to check
Returns:True: if SmartHomeNG is running, False: if SmartHome is not running
Return type:bool
lib.daemon.daemonize(pidfile, stdin='/dev/null', stdout='/dev/null', stderr=None)[source]

This method domonizes the sh.py process and redirects standard file descriptors.

Parameters:
  • pidfile (string) – Path to pidfile
  • stdin (string) – Path to new stdin, default value is “/dev/null”
  • stdout (string) – Path to new stdout, default value is “/dev/null”
  • stderr (string) – Path to new stderr, default value is None, but if stderr is None it is mapped to stdout
lib.daemon.kill(pidfile, waittime=15)[source]

This method kills the process identified by pidfile.

Parameters:
  • pidfile (str) – Name of the pidfile identifying the process to kill
  • waittime (int) – Number of seconds to wait before killing the process
lib.daemon.read_pidfile(pidfile)[source]

This method reads the pidfile and returns the PID.

Parameters:pidfile (str) – Name of the pidfile to check
Returns:PID of SmartHomeNG or 0 if it is not running
Return type:int
lib.daemon.remove_pidfile(pidfile)[source]

This method removes the pidfile.

Parameters:pidfile (str) – Name of the pidfile to write to
lib.daemon.write_pidfile(pid, pidfile)[source]

This method writes the PID to the pidfile and locks it while the process is running.

Parameters:
  • pid (int) – PID of SmartHomeNG
  • pidfile (str) – Name of the pidfile to write to