lib.daemon

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

lib.daemon.check_sh_is_running(pidfile)[Quellcode]

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

Parameter

pidfile (str) – Name of the pidfile to check

Rückgabe

True: if SmartHomeNG is running, False: if SmartHome is not running

Rückgabetyp

bool

lib.daemon.daemonize(pidfile, stdin='/dev/null', stdout='/dev/null', stderr=None)[Quellcode]

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

Parameter
  • 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)[Quellcode]

This method kills the process identified by pidfile.

Parameter
  • 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)[Quellcode]

This method reads the pidfile and returns the PID.

Parameter

pidfile (str) – Name of the pidfile to check

Rückgabe

PID of SmartHomeNG or 0 if it is not running

Rückgabetyp

int

lib.daemon.remove_pidfile(pidfile)[Quellcode]

This method removes the pidfile.

Parameter

pidfile (str) – Name of the pidfile to write to

lib.daemon.write_pidfile(pid, pidfile)[Quellcode]

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

Parameter
  • pid (int) – PID of SmartHomeNG

  • pidfile (str) – Name of the pidfile to write to