コード例 #1
0
def check_future_exception_and_log(future):
    from circle import logger
    if isinstance(future, concurrent.Future):
        exception = future.exception()
        if exception is not None:
            logger.error('exception {} caught'.format(exception))
            if hasattr(future, 'exc_info'):
                exc_info = future.exc_info()
                traceback.print_tb(exc_info[2])
            return exception
コード例 #2
0
    def signal(self, sig, frame=None):
        signame = self.SIG_NAMES.get(sig)
        logger.info('Got signal SIG_{}'.format(signame.upper()))

        if signame is not None:
            try:
                handler = getattr(self, "handle_%s" % signame)
                handler()
            except AttributeError:
                pass
            except Exception as e:
                tb = traceback.format_exc()
                logger.error("error: %s [%s]" % (e, tb))
                sys.exit(1)
コード例 #3
0
def win_daemonize():
    logger.info('Starting deamon mode. '
                'The AntCircled service will be started.')
    args = sys.argv[1:]
    if '--daemon' in args:
        args.remove('--daemon')
    try:
        if not CircleWinService.exists():
            CircleWinService.install(*args)
            CircleWinService.start(*args)
            sys.exit(0)
    except (AlreadyExist, NotExistError, CallError) as e:
        logger.error(e)
        sys.exit(1)
コード例 #4
0
    def run_hooks(self, hook_name):
        hooks = self.config.get('hooks', None)
        if not hooks:
            raise gen.Return(True)

        hook = hooks.get(hook_name, None)

        if not hook:
            logger.info('Watcher: "{}" have no {} hooks'.format(
                self.name, hook_name))
            raise gen.Return(True)

        self.running_hook = True
        logger.info('Watcher: "{}" run {} hooks'.format(self.name, hook_name))
        status, output = yield async_get_status_output(hook,
                                                       cwd=self.working_dir)
        self.running_hook = False
        if status:
            logger.error(output)
            raise gen.Return(False)
        raise gen.Return(True)
コード例 #5
0
    def _dispatch_callback(self, msg, mid, cmd_name, resp=None):
        if resp is None:
            resp = ok()

        if not isinstance(resp, (dict, list)):
            msg = 'Message {!r} tried to send a non-dict: {}'\
                .format(msg, str(resp))
            logger.error(msg)
            return self.send_error(mid,
                                   msg,
                                   error('server error'),
                                   errno=errors.BAD_MSG_DATA_ERROR)

        if isinstance(resp, list):
            resp = {'results': resp}

        self.send_ok(mid, msg, resp)

        if cmd_name.lower() == 'quit':
            self.controller.arbiter.stop()
            if IS_WINDOWS and CircleWinService.status() == 'running':
                CircleWinService.stop()