def run_notify(self, socket_path, n, options): middleware = [FalconLabel(self.translations)] if options.with_metrics: middleware.append(FalconMetrics()) if PROFILE_DIR and PROFILE_MODE == 'request': middleware.append(FalconRequestProfiler()) backends = options.backends.split(',') app = grapi.API(options=options, middleware=middleware, backends=backends, components=('notification', )) # Add our own exception handler and backend specific error handlers, # error handlers in falcon adhere to LIFO order, meaning our generic # exception handler should always be inserted first. handler = partial(error_handler, with_metrics=options.with_metrics) app.add_error_handler(Exception, handler) app.initialize_backends_error_handlers() unix_socket_path = os.path.join(socket_path, 'notify%d.sock' % n) # Run server, this blocks. logging.debug('starting notify %d worker (unix:%s) with pid %d', n, unix_socket_path, os.getpid()) bjoern.server_run(self.create_socket_and_listen(unix_socket_path), app)
def run_notify(self, socket_path, n, options): middleware = [FalconLabel(self.translations)] if options.with_metrics: middleware.append(FalconMetrics()) if PROFILE_DIR and PROFILE_MODE == 'request': middleware.append(FalconRequestProfiler()) backends = options.backends.split(',') app = grapi.NotifyAPI(options=options, middleware=middleware, backends=backends) handler = partial(error_handler, with_metrics=options.with_metrics) app.add_error_handler(Exception, handler) unix_socket_path = os.path.join(socket_path, 'notify%d.sock' % n) # Run server, this blocks. logging.debug('starting notify %d worker (unix:%s) with pid %d', n, unix_socket_path, os.getpid()) bjoern.server_run(self.create_socket_and_listen(unix_socket_path), app)
def run_rest(self, socket_path, n, options): middleware = [FalconLabel(self.translations)] if options.with_metrics: middleware.append(FalconMetrics()) if WITH_CPROFILE and PROFILE_DIR: middleware.append(FalconRequestProfiler()) backends = options.backends.split(',') app = grapi.API(options=options, middleware=middleware, backends=backends, components=('directory', 'mail', 'calendar', 'reminder')) handler = partial(error_handler, with_metrics=options.with_metrics) app.add_error_handler(Exception, handler) unix_socket_path = os.path.join(socket_path, 'rest%d.sock' % n) # Run server, this blocks. logging.debug('starting rest %d worker (unix:%s) with pid %d', n, unix_socket_path, os.getpid()) bjoern.server_run(self.create_socket_and_listen(unix_socket_path), app)
from werkzeug.debug import DebuggedApplication application = DebuggedApplication(application, evalex=True, pin_security=True, pin_logging=True) application.debug = True # bjoern.run(application, 'unix:/data/sockets/bjoern-mhackspace.sock') #https://stackoverflow.com/questions/46301706/bjoern-wsgi-server-unix-socket-permissions # class ReloadApplicationMiddleware(object): # def __call__(self, *args, **kwargs): # print('Reloading...') # self.app = self.import_func() # return self.app(*args, **kwargs) # application = ReloadApplicationMiddleware(application) socket_path = '/data/sockets/bjoern-mhackspace.sock' if os.path.exists(socket_path): os.unlink(socket_path) sock = socket.socket(socket.AF_UNIX) sock.bind(socket_path) sock.listen(1024) os.chmod(socket_path, 0o666) try: bjoern.server_run(sock, application) except KeyboardInterrupt: os.unlink(sock.getsockname()) sock.close()
def serve_forever(self): bjoern.server_run(self.sock, self.app)
def serve_forever(self): bjoern.server_run(self.sock, self.app)
def serve_forever(self): """ Run server. """ bjoern.server_run(self.socket, self.application)
def serve_forever(self): """ Run server. """ bjoern.server_run(self.socket, self.application)