Пример #1
0
    def lsof(self, service):
        '''"lsof" a service's processes.
        '''

        return setResponsePlainText(
            check_output('/usr/sbin/lsof -p %s' %
                         ','.join(keeper.getPIDs(service)),
                         shell=True))
Пример #2
0
    def lsof(self, service):
        '''"lsof" a service's processes.
        '''

        return setResponsePlainText(check_output('/usr/sbin/lsof -p %s' % ','.join(keeper.getPIDs(service)), shell = True))
Пример #3
0
    def index(self):
        '''Status page.
        '''

        table = '''
            <tr>
                <th>Service</th>
                <th>Jobs</th>
                <th>Status</th>
                <th>Link</th>
                <th>Actions</th>
            </tr>
        '''

        def makeAction(service, action, disabled=False):
            actionTemplate = '''
                <form action="%s" method="get"><input name="service" type="hidden" value="%s" /><input value="%s" type="submit" %s /></form>
            '''

            disabledText = ''
            if disabled:
                disabledText = 'disabled="disabled"'

            return actionTemplate % (action, service, action, disabledText)

        for service in ['keeper'
                        ] + config.getServicesList(showHiddenServices=True):
            jobs = ''
            status = ''
            url = ''

            enabledJobs = keeper.hasEnabledJobs(service)
            if enabledJobs:
                jobs = 'Enabled'

            pids = keeper.getPIDs(service)
            running = len(pids) > 0
            if running:
                status = ','.join(pids)

                url = '/%s/' % service
                if service != 'keeper':
                    url = '<a href="%s">%s</a>' % (url, url)

            # FIXME: Add the ability to restart/stop/kill the admin service via a proxy process
            #        and returning a proper message to the user.
            actions = ''
            for action in ['tail', 'logs', 'joblogs']:
                actions += makeAction(service, action)
            for action in ['lsof', 'env']:
                actions += makeAction(service, action, not running)
            for action in ['start']:
                actions += makeAction(service, action, running
                                      or service == 'admin')
            for action in ['stop', 'restart', 'kill']:
                actions += makeAction(service, action, not running
                                      or service == 'admin')
            for action in ['enableJobs']:
                actions += makeAction(service, action, enabledJobs
                                      or service == 'keeper')
            for action in ['disableJobs']:
                actions += makeAction(service, action, not enabledJobs
                                      or service == 'keeper')

            table += '''
                <tr>
                    <td>%s</td>
                    <td>%s</td>
                    <td>%s</td>
                    <td>%s</td>
                    <td>%s</td>
                </tr>
            ''' % (service, jobs, status, url, actions)

        return indexTemplate.render(table=table)
Пример #4
0
    def index(self):
        '''Status page.
        '''

        table = '''
            <tr>
                <th>Service</th>
                <th>Jobs</th>
                <th>Status</th>
                <th>Link</th>
                <th>Actions</th>
            </tr>
        '''

        def makeAction(service, action, disabled = False):
            actionTemplate = '''
                <form action="%s" method="get"><input name="service" type="hidden" value="%s" /><input value="%s" type="submit" %s /></form>
            '''

            disabledText = ''
            if disabled:
                disabledText = 'disabled="disabled"'

            return actionTemplate % (action, service, action, disabledText)

        for service in ['keeper'] + config.getServicesList(showHiddenServices = True):
            jobs = ''
            status = ''
            url = ''

            enabledJobs = keeper.hasEnabledJobs(service)
            if enabledJobs:
                jobs = 'Enabled'

            pids = keeper.getPIDs(service)
            running = len(pids) > 0
            if running:
                status = ','.join(pids)

                url = '/%s/' % service
                if service != 'keeper':
                    url = '<a href="%s">%s</a>' % (url, url)

            # FIXME: Add the ability to restart/stop/kill the admin service via a proxy process
            #        and returning a proper message to the user.
            actions = ''
            for action in ['tail', 'logs', 'joblogs']:
                actions += makeAction(service, action)
            for action in ['lsof', 'env']:
                actions += makeAction(service, action, not running)
            for action in ['start']:
                actions += makeAction(service, action, running or service == 'admin')
            for action in ['stop', 'restart', 'kill']:
                actions += makeAction(service, action, not running or service == 'admin')
            for action in ['enableJobs']:
                actions += makeAction(service, action, enabledJobs or service == 'keeper')
            for action in ['disableJobs']:
                actions += makeAction(service, action, not enabledJobs or service == 'keeper')

            table += '''
                <tr>
                    <td>%s</td>
                    <td>%s</td>
                    <td>%s</td>
                    <td>%s</td>
                    <td>%s</td>
                </tr>
            ''' % (service, jobs, status, url, actions)

        return indexTemplate.render(table = table)