예제 #1
0
    def __init__(self, stdin='/dev/null', stdout=LOGFILE, stderr=LOGFILE):
        self.stdin = stdin
        self.stdout = stdout
        self.stderr = stderr

        if glib2reactor_installed:
            r = glib2reactor
        else:
            r = reactor

        signal.signal(signal.SIGINT, lambda s, f: exit_brickd(s, f, r))
        signal.signal(signal.SIGTERM, lambda s, f: exit_brickd(s, f, r))
예제 #2
0
 def __init__(self, stdin='/dev/null', stdout=LOGFILE, stderr=LOGFILE):
     self.stdin = stdin
     self.stdout = stdout
     self.stderr = stderr
     
     if glib2reactor_installed:
         r = glib2reactor
     else:
         r = reactor
     
     signal.signal(signal.SIGINT, lambda s, f: exit_brickd(s, f, r)) 
     signal.signal(signal.SIGTERM, lambda s, f: exit_brickd(s, f, r)) 
예제 #3
0
    def start(self):
        logging.info("brickd started")
        
        from twisted.internet import reactor

        r = reactor
        signal.signal(signal.SIGINT, lambda s, f: exit_brickd(s, f, r)) 
        signal.signal(signal.SIGTERM, lambda s, f: exit_brickd(s, f, r)) 

        self.usb_notifier = USBNotifier()
        self.osx_notifier_thread = Thread(target=osx_notifier, args=(self,))
        self.osx_notifier_thread.daemon = True
        self.osx_notifier_thread.start()

        reactor.listenTCP(config.PORT, BrickProtocolFactory())
        try:
            reactor.run(installSignalHandlers = True)
        except KeyboardInterrupt:
            reactor.stop()