How to use the pgctl.functions.bestrelpath function in pgctl

To help you get started, we’ve selected a few pgctl examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github Yelp / pgctl / tests / unit / functions.py View on Github external
def it_prefers_shorter_strings(self):
        assert bestrelpath('/a/b/c', '/a/b') == 'c'
        assert bestrelpath('/a/b', '/a/b/c') == '/a/b'
        assert bestrelpath('/a/b', '/a/b/c/d') == '/a/b'
github Yelp / pgctl / tests / unit / functions.py View on Github external
def it_prefers_shorter_strings(self):
        assert bestrelpath('/a/b/c', '/a/b') == 'c'
        assert bestrelpath('/a/b', '/a/b/c') == '/a/b'
        assert bestrelpath('/a/b', '/a/b/c/d') == '/a/b'
github Yelp / pgctl / pgctl / service.py View on Github external
def ensure_exists(self):
        if self.__exists:
            return

        if not self.path.check(dir=True):
            raise NoSuchService("No such service: '%s'" % bestrelpath(str(self.path)))

        self._ensure_supervise_is_scratch('supervise')
        self.__exists = True
github Yelp / pgctl / pgctl / cli.py View on Github external
failapp = self.with_services(failed)
        childpid = os.fork()
        if childpid:
            os.waitpid(childpid, 0)
        else:
            os.dup2(2, 1)  # send log to stderr
            failapp.log(interactive=False)  # doesn't return
        if state == 'start':
            # we don't want services that failed to start to be 'up'
            failapp.stop()

        pgctl_print()
        pgctl_print('There might be useful information further up in the log; you can view it by running:')
        for service in failapp.services:
            pgctl_print('    less +G {}'.format(bestrelpath(service.path.join('logs', 'current').strpath)))

        raise PgctlUserMessage('Some services failed to %s: %s' % (state, commafy(failed)))
github Yelp / pgctl / pgctl / cli.py View on Github external
# TODO(p3): -f: force iteractive behavior
        # TODO(p3): -F: force iteractive behavior off
        tail = ('tail', '-n', '30', '--verbose')  # show file headers

        if interactive is None:
            interactive = sys.stdout.isatty()
        if interactive:
            # we're interactive; give a continuous log
            # TODO-TEST: pgctl log | pb should be non-interactive
            tail += ('--follow=name', '--retry')

        logfiles = []
        for service in self.services:
            service.ensure_logs()
            logfile = service.path.join('logs', 'current')
            logfile = bestrelpath(str(logfile))
            logfiles.append(logfile)
        exec_(tail + tuple(logfiles))  # never returns