Example #1
0
 def start(self):
     '''
     Start the daemon.
     '''
     if self.child_pid is not None:
         # TODO: raise an error (child is already running)
         return
     (self.child_pid, self.child_stdout) = self.start_command.run()
     if self.child_stdout is not None:
         _fd.close_on_exec(self.child_stdout)
Example #2
0
 def __init__(self, filename):
     '''
     :param filename: name of the pid file
     :type filename: string
     '''
     self.filename = os.path.abspath(filename)
     self.fd = open(self.filename, 'w', 0) # TODO: atomic create-or-fail
     _fd.close_on_exec(self.fd)
     self.pid = None
     self.remove_on_close = False
     self.update()
 def __init__(self, address):
     '''
     :param address: address to bind to
     :type address: string
     '''
     self.path = os.path.abspath(address)
     self.socket = None
     conn = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM)
     conn.bind(self.path)
     # only set self.socket it after bind(), so the file won't get removed
     # when it's not ours (e.g. existed already)
     self.socket = conn
     _fd.close_on_exec(self.socket)
     self.socket.listen(1)