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


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 daemonizes the process and redirects standard file descriptors.

  • 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.

  • pidfile (str) – Name of the pidfile identifying the process to kill
  • waittime (int) – Number of seconds to wait before killing the process

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

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.

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