docs: def daemonize(self):
          """
          Do the UNIX double-fork magic, see Stevens' "Advanced
          Programming in the UNIX Environment" for details (ISBN 0201563177)
          http://www.erlenstar.demon.co.uk/unix/faq_2.html#SEC16
          """
          try:
              pid = os.fork()
              if pid > 0:
                  sys.exit(0)
          except OSError as e:
              sys.stderr.write('fork #1 failed: %d (%s)\n' %
                               (e.errno, e.strerror))
              sys.exit(1)
          os.chdir('/')
          os.setsid()
          os.umask(0)
          try:
              pid = os.fork()
              if pid > 0:
                  sys.exit(0)
          except OSError as e:
              sys.stderr.write('fork #2 failed: %d (%s)\n' %
                               (e.errno, e.strerror))
              sys.exit(1)
          # to properly close the fd's, we need to use sys and os:
          # http://chromano.me/2011/05/23/starting-python-daemons-via-ssh.html
          sys.stdin.close()
          sys.stdout.close()
          sys.stderr.close()
          os.closerange(0, 3)
  
          pid = os.getpid()
          with open(self.pid_file, 'w+') as fp:
              fp.write("%s\n" % pid)
  
          def handler(*args):
              raise BaseException("SIGTERM was caught")
          signal.signal(signal.SIGTERM, handler)
          # atexit functions are "not called when the program is killed by a
          # signal not handled by Python". But since SIGTERM is now handled, the
          # atexit functions do get called.
          atexit.register(self._shutdown)