# HG changeset patch # User Marcin Kuzminski # Date 2017-11-08 11:22:35 # Node ID f18d95e5476340fb6e5ba45276a6b32fe3f0f840 # Parent 1cd7c646177a41a9abc05295d42502ec6f1f6b02 settings: removed not used supervisor views/models. - this isn't going anywhere, and it's a dead code that has been replaced by the processes page. diff --git a/rhodecode/apps/admin/navigation.py b/rhodecode/apps/admin/navigation.py --- a/rhodecode/apps/admin/navigation.py +++ b/rhodecode/apps/admin/navigation.py @@ -101,9 +101,6 @@ class NavigationRegistry(object): NavEntry('open_source', _('Open Source Licenses'), 'admin_settings_open_source', pyramid=True), - # TODO: marcink: we disable supervisor now until the supervisor stats - # page is fixed in the nix configuration - # NavEntry('supervisor', _('Supervisor'), 'admin_settings_supervisor'), ] _labs_entry = NavEntry('labs', _('Labs'), 'admin_settings_labs') diff --git a/rhodecode/config/middleware.py b/rhodecode/config/middleware.py --- a/rhodecode/config/middleware.py +++ b/rhodecode/config/middleware.py @@ -145,7 +145,9 @@ def make_pyramid_app(global_config, **se add_pylons_compat_data(config.registry, global_config, settings.copy()) + # Static file view comes first includeme_first(config) + includeme(config) pyramid_app = config.make_wsgi_app() diff --git a/rhodecode/config/routing.py b/rhodecode/config/routing.py --- a/rhodecode/config/routing.py +++ b/rhodecode/config/routing.py @@ -241,11 +241,6 @@ def make_map(config): m.connect('admin_settings_search', '/settings/search', action='settings_search', conditions={'method': ['GET']}) - m.connect('admin_settings_supervisor', '/settings/supervisor', - action='settings_supervisor', conditions={'method': ['GET']}) - m.connect('admin_settings_supervisor_log', '/settings/supervisor/{procid}/log', - action='settings_supervisor_log', conditions={'method': ['GET']}) - m.connect('admin_settings_labs', '/settings/labs', action='settings_labs_update', conditions={'method': ['POST']}) diff --git a/rhodecode/controllers/admin/settings.py b/rhodecode/controllers/admin/settings.py --- a/rhodecode/controllers/admin/settings.py +++ b/rhodecode/controllers/admin/settings.py @@ -47,7 +47,6 @@ from rhodecode.lib.celerylib import task from rhodecode.lib.utils import repo2db_mapper from rhodecode.lib.utils2 import ( str2bool, safe_unicode, AttributeDict, safe_int) -from rhodecode.lib.compat import OrderedDict from rhodecode.model.db import RhodeCodeUi, Repository from rhodecode.model.forms import ApplicationSettingsForm, \ @@ -62,8 +61,6 @@ from rhodecode.model.settings import ( IssueTrackerSettingsModel, VcsSettingsModel, SettingNotFound, SettingsModel) -from rhodecode.model.supervisor import SupervisorModel, SUPERVISOR_MASTER - log = logging.getLogger(__name__) @@ -545,69 +542,6 @@ class SettingsController(BaseController) return render('admin/settings/settings.mako') @HasPermissionAllDecorator('hg.admin') - def settings_supervisor(self): - c.rhodecode_ini = rhodecode.CONFIG - c.active = 'supervisor' - - c.supervisor_procs = OrderedDict([ - (SUPERVISOR_MASTER, {}), - ]) - - c.log_size = 10240 - supervisor = SupervisorModel() - - _connection = supervisor.get_connection( - c.rhodecode_ini.get('supervisor.uri')) - c.connection_error = None - try: - _connection.supervisor.getAllProcessInfo() - except Exception as e: - c.connection_error = str(e) - log.exception("Exception reading supervisor data") - return render('admin/settings/settings.mako') - - groupid = c.rhodecode_ini.get('supervisor.group_id') - - # feed our group processes to the main - for proc in supervisor.get_group_processes(_connection, groupid): - c.supervisor_procs[proc['name']] = {} - - for k in c.supervisor_procs.keys(): - try: - # master process info - if k == SUPERVISOR_MASTER: - _data = supervisor.get_master_state(_connection) - _data['name'] = 'supervisor master' - _data['description'] = 'pid %s, id: %s, ver: %s' % ( - _data['pid'], _data['id'], _data['ver']) - c.supervisor_procs[k] = _data - else: - procid = groupid + ":" + k - c.supervisor_procs[k] = supervisor.get_process_info(_connection, procid) - except Exception as e: - log.exception("Exception reading supervisor data") - c.supervisor_procs[k] = {'_rhodecode_error': str(e)} - - return render('admin/settings/settings.mako') - - @HasPermissionAllDecorator('hg.admin') - def settings_supervisor_log(self, procid): - import rhodecode - c.rhodecode_ini = rhodecode.CONFIG - c.active = 'supervisor_tail' - - supervisor = SupervisorModel() - _connection = supervisor.get_connection(c.rhodecode_ini.get('supervisor.uri')) - groupid = c.rhodecode_ini.get('supervisor.group_id') - procid = groupid + ":" + procid if procid != SUPERVISOR_MASTER else procid - - c.log_size = 10240 - offset = abs(safe_int(request.GET.get('offset', c.log_size))) * -1 - c.log = supervisor.read_process_log(_connection, procid, offset, 0) - - return render('admin/settings/settings.mako') - - @HasPermissionAllDecorator('hg.admin') @auth.CSRFRequired() def settings_labs_update(self): """POST /admin/settings/labs: All items in the collection""" diff --git a/rhodecode/model/supervisor.py b/rhodecode/model/supervisor.py deleted file mode 100644 --- a/rhodecode/model/supervisor.py +++ /dev/null @@ -1,92 +0,0 @@ -# -*- coding: utf-8 -*- - -# Copyright (C) 2014-2017 RhodeCode GmbH -# -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU Affero General Public License, version 3 -# (only), as published by the Free Software Foundation. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU Affero General Public License -# along with this program. If not, see . -# -# This program is dual-licensed. If you wish to learn more about the -# RhodeCode Enterprise Edition, including its added features, Support services, -# and proprietary license terms, please see https://rhodecode.com/licenses/ - - -""" -Model for supervisor process manager -""" - -import xmlrpclib -import logging -import traceback - -import rhodecode -from rhodecode.model import BaseModel - -log = logging.getLogger(__name__) - - -SUPERVISOR_MASTER = 'MASTER' # special name for supervisor master process - - -class SupervisorModel(BaseModel): - - cls = None - - def __init__(self, sa=None): - super(SupervisorModel, self).__init__(sa=sa) - - def _verify_connection(self, connection): - if not isinstance(connection, xmlrpclib.ServerProxy): - raise Exception('Invalid connection given, got %s, expected %s' - % (type(connection), xmlrpclib.ServerProxy)) - - def get_connection(self, supervisor_uri): - uri = supervisor_uri or 'http://' - try: - server_connection = xmlrpclib.ServerProxy(uri) - return server_connection - except Exception as e: - log.error(traceback.format_exc()) - raise - - def get_master_log(self, connection, offset, length): - self._verify_connection(connection) - return connection.supervisor.readLog(offset, length) - - def get_master_state(self, connection): - self._verify_connection(connection) - _data = connection.supervisor.getState() - _data.update({'pid': connection.supervisor.getPID()}) - _data.update({'id': connection.supervisor.getIdentification()}) - _data.update({'ver': connection.supervisor.getSupervisorVersion()}) - return _data - - def get_group_processes(self, connection, groupid): - self._verify_connection(connection) - res = [] - for data in connection.supervisor.getAllProcessInfo(): - if data['group'] == groupid: - res.append(data) - return res - - def get_process_info(self, connection, procid): - self._verify_connection(connection) - - return connection.supervisor.getProcessInfo(procid) - - def read_process_log(self, connection, procid, offset, length): - self._verify_connection(connection) - if procid == SUPERVISOR_MASTER: - log = self.get_master_log(connection, offset, length) - else: - log = connection.supervisor.readProcessLog(procid, offset, length) - # make sure we just return whole lines not to confuse people - return ''.join(log.splitlines(1)[1:])