process-management: enable auto-refresh to track usage live.
This commit is contained in:
parent
565d2d984a
commit
5c4f5f9f2c
5 changed files with 159 additions and 81 deletions
|
|
@ -69,6 +69,9 @@ def admin_routes(config):
|
|||
config.add_route(
|
||||
name='admin_settings_process_management',
|
||||
pattern='/settings/process_management')
|
||||
config.add_route(
|
||||
name='admin_settings_process_management_data',
|
||||
pattern='/settings/process_management/data')
|
||||
config.add_route(
|
||||
name='admin_settings_process_management_signal',
|
||||
pattern='/settings/process_management/signal')
|
||||
|
|
|
|||
|
|
@ -53,6 +53,18 @@ class AdminProcessManagementView(BaseAppView):
|
|||
p for p in psutil.process_iter() if 'gunicorn' in p.name())
|
||||
return self._get_template_context(c)
|
||||
|
||||
@LoginRequired()
|
||||
@HasPermissionAllDecorator('hg.admin')
|
||||
@view_config(
|
||||
route_name='admin_settings_process_management_data', request_method='GET',
|
||||
renderer='rhodecode:templates/admin/settings/settings_process_management_data.mako')
|
||||
def process_management_data(self):
|
||||
_ = self.request.translate
|
||||
c = self.load_default_context()
|
||||
c.gunicorn_processes = (
|
||||
p for p in psutil.process_iter() if 'gunicorn' in p.name())
|
||||
return self._get_template_context(c)
|
||||
|
||||
@LoginRequired()
|
||||
@HasPermissionAllDecorator('hg.admin')
|
||||
@CSRFRequired()
|
||||
|
|
|
|||
|
|
@ -48,6 +48,7 @@ function registerRCRoutes() {
|
|||
pyroutes.register('admin_settings_sessions', '/_admin/settings/sessions', []);
|
||||
pyroutes.register('admin_settings_sessions_cleanup', '/_admin/settings/sessions/cleanup', []);
|
||||
pyroutes.register('admin_settings_process_management', '/_admin/settings/process_management', []);
|
||||
pyroutes.register('admin_settings_process_management_data', '/_admin/settings/process_management/data', []);
|
||||
pyroutes.register('admin_settings_process_management_signal', '/_admin/settings/process_management/signal', []);
|
||||
pyroutes.register('admin_defaults_repositories', '/_admin/defaults/repositories', []);
|
||||
pyroutes.register('admin_defaults_repositories_update', '/_admin/defaults/repositories/update', []);
|
||||
|
|
@ -283,6 +284,7 @@ function registerRCRoutes() {
|
|||
pyroutes.register('my_account_ssh_keys_generate', '/_admin/my_account/ssh_keys/generate', []);
|
||||
pyroutes.register('my_account_ssh_keys_add', '/_admin/my_account/ssh_keys/new', []);
|
||||
pyroutes.register('my_account_ssh_keys_delete', '/_admin/my_account/ssh_keys/delete', []);
|
||||
pyroutes.register('my_account_user_group_membership', '/_admin/my_account/user_group_membership', []);
|
||||
pyroutes.register('my_account_emails', '/_admin/my_account/emails', []);
|
||||
pyroutes.register('my_account_emails_add', '/_admin/my_account/emails/new', []);
|
||||
pyroutes.register('my_account_emails_delete', '/_admin/my_account/emails/delete', []);
|
||||
|
|
|
|||
|
|
@ -7,7 +7,10 @@
|
|||
<div class="panel panel-default">
|
||||
<div class="panel-heading">
|
||||
<h3 class="panel-title">${_('Gunicorn process management')}</h3>
|
||||
|
||||
<div class="pull-right">
|
||||
<a id="autoRefreshEnable" href="#autoRefreshEnable" onclick="enableAutoRefresh(); return false">${_('start auto refresh')}</a>
|
||||
<a id="autoRefreshDisable" href="#autoRefreshDisable" onclick="disableAutoRefresh(); return false" style="display: none">${_('stop auto refresh')}</a>
|
||||
</div>
|
||||
</div>
|
||||
<div class="panel-body" id="app">
|
||||
<h3>List of Gunicorn processes on this machine</h3>
|
||||
|
|
@ -20,88 +23,10 @@
|
|||
return 'RhodeCode'
|
||||
return proc.name()
|
||||
%>
|
||||
<table>
|
||||
% for proc in c.gunicorn_processes:
|
||||
<% mem = proc.memory_info()%>
|
||||
<% children = proc.children(recursive=True) %>
|
||||
% if children:
|
||||
|
||||
<tr>
|
||||
<td>
|
||||
<code>
|
||||
${proc.pid} - ${get_name(proc)}
|
||||
</code>
|
||||
</td>
|
||||
<td>
|
||||
<a href="#showCommand" onclick="$('#pid'+${proc.pid}).toggle();return false"> command </a>
|
||||
<code id="pid${proc.pid}" style="display: none">
|
||||
${' '.join(proc.cmdline())}
|
||||
</code>
|
||||
</td>
|
||||
<td></td>
|
||||
<td>
|
||||
RSS:${h.format_byte_size_binary(mem.rss)}
|
||||
</td>
|
||||
<td>
|
||||
VMS:${h.format_byte_size_binary(mem.vms)}
|
||||
</td>
|
||||
<td>
|
||||
AGE: ${h.age_component(h.time_to_utcdatetime(proc.create_time()))}
|
||||
</td>
|
||||
<td>
|
||||
MASTER
|
||||
</td>
|
||||
</tr>
|
||||
<% mem_sum = 0 %>
|
||||
% for proc_child in children:
|
||||
<% mem = proc_child.memory_info()%>
|
||||
<tr>
|
||||
<td>
|
||||
<code>
|
||||
| ${proc_child.pid} - ${get_name(proc_child)}
|
||||
</code>
|
||||
</td>
|
||||
<td>
|
||||
<a href="#showCommand" onclick="$('#pid'+${proc_child.pid}).toggle();return false"> command </a>
|
||||
<code id="pid${proc_child.pid}" style="display: none">
|
||||
${' '.join(proc_child.cmdline())}
|
||||
</code>
|
||||
</td>
|
||||
<td>
|
||||
CPU: ${proc_child.cpu_percent()} %
|
||||
</td>
|
||||
<td>
|
||||
RSS:${h.format_byte_size_binary(mem.rss)}
|
||||
<% mem_sum += mem.rss %>
|
||||
</td>
|
||||
<td>
|
||||
VMS:${h.format_byte_size_binary(mem.vms)}
|
||||
</td>
|
||||
<td>
|
||||
AGE: ${h.age_component(h.time_to_utcdatetime(proc_child.create_time()))}
|
||||
</td>
|
||||
<td>
|
||||
<a href="#restartProcess" onclick="restart(this, ${proc_child.pid});return false">
|
||||
restart
|
||||
</a>
|
||||
</td>
|
||||
</tr>
|
||||
% endfor
|
||||
<tr>
|
||||
<td colspan="2"><code>| total processes: ${len(children)}</code></td>
|
||||
<td></td>
|
||||
<td><strong>RSS:${h.format_byte_size_binary(mem_sum)}</strong></td>
|
||||
<td></td>
|
||||
</tr>
|
||||
<tr><td> <code> -- </code> </td></tr>
|
||||
|
||||
% endif
|
||||
% endfor
|
||||
</table>
|
||||
<%include file='settings_process_management_data.mako'/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
<script>
|
||||
|
||||
|
||||
|
|
@ -135,7 +60,50 @@ restart = function(elem, pid) {
|
|||
$(elem).removeClass('disabled');
|
||||
}
|
||||
})
|
||||
}
|
||||
};
|
||||
|
||||
var intervalID = null;
|
||||
var currentRequest = null;
|
||||
|
||||
autoRefresh = function(value) {
|
||||
var url = pyroutes.url('admin_settings_process_management_data');
|
||||
var loadData = function() {
|
||||
currentRequest = $.get(url)
|
||||
.done(function(data) {
|
||||
currentRequest = null;
|
||||
$('#procList').html(data);
|
||||
timeagoActivate();
|
||||
var beat = function(doCallback) {
|
||||
var callback = function () {};
|
||||
if (doCallback){
|
||||
var callback = function () {beat(false)};
|
||||
}
|
||||
$('#processTimeStamp').animate({
|
||||
opacity: $('#processTimeStamp').css('opacity') == '1' ? '0.3' : '1'
|
||||
}, 500, callback);
|
||||
};
|
||||
beat(true)
|
||||
});
|
||||
};
|
||||
|
||||
if (value) {
|
||||
intervalID = setInterval(loadData, 5000);
|
||||
} else {
|
||||
clearInterval(intervalID);
|
||||
}
|
||||
};
|
||||
|
||||
enableAutoRefresh = function() {
|
||||
$('#autoRefreshEnable').hide();
|
||||
$('#autoRefreshDisable').show();
|
||||
autoRefresh(true)
|
||||
};
|
||||
|
||||
disableAutoRefresh = function() {
|
||||
$('#autoRefreshEnable').show();
|
||||
$('#autoRefreshDisable').hide();
|
||||
autoRefresh(false)
|
||||
};
|
||||
|
||||
|
||||
</script>
|
||||
|
|
|
|||
|
|
@ -0,0 +1,93 @@
|
|||
|
||||
<table id="procList">
|
||||
<%
|
||||
def get_name(proc):
|
||||
cmd = ' '.join(proc.cmdline())
|
||||
if 'vcsserver.ini' in cmd:
|
||||
return 'VCSServer'
|
||||
elif 'rhodecode.ini' in cmd:
|
||||
return 'RhodeCode'
|
||||
return proc.name()
|
||||
%>
|
||||
<tr>
|
||||
<td colspan="8">
|
||||
<span id="processTimeStamp">${h.format_date(h.datetime.now())}</span>
|
||||
</td>
|
||||
</tr>
|
||||
% for proc in c.gunicorn_processes:
|
||||
<% mem = proc.memory_info()%>
|
||||
<% children = proc.children(recursive=True) %>
|
||||
% if children:
|
||||
|
||||
<tr>
|
||||
<td>
|
||||
<code>
|
||||
${proc.pid} - ${get_name(proc)}
|
||||
</code>
|
||||
</td>
|
||||
<td>
|
||||
<a href="#showCommand" onclick="$('#pid'+${proc.pid}).toggle();return false"> command </a>
|
||||
<code id="pid${proc.pid}" style="display: none">
|
||||
${' '.join(proc.cmdline())}
|
||||
</code>
|
||||
</td>
|
||||
<td></td>
|
||||
<td>
|
||||
RSS:${h.format_byte_size_binary(mem.rss)}
|
||||
</td>
|
||||
<td>
|
||||
VMS:${h.format_byte_size_binary(mem.vms)}
|
||||
</td>
|
||||
<td>
|
||||
AGE: ${h.age_component(h.time_to_utcdatetime(proc.create_time()))}
|
||||
</td>
|
||||
<td>
|
||||
MASTER
|
||||
</td>
|
||||
</tr>
|
||||
<% mem_sum = 0 %>
|
||||
% for proc_child in children:
|
||||
<% mem = proc_child.memory_info()%>
|
||||
<tr>
|
||||
<td>
|
||||
<code>
|
||||
| ${proc_child.pid} - ${get_name(proc_child)}
|
||||
</code>
|
||||
</td>
|
||||
<td>
|
||||
<a href="#showCommand" onclick="$('#pid'+${proc_child.pid}).toggle();return false"> command </a>
|
||||
<code id="pid${proc_child.pid}" style="display: none">
|
||||
${' '.join(proc_child.cmdline())}
|
||||
</code>
|
||||
</td>
|
||||
<td>
|
||||
CPU: ${proc_child.cpu_percent()} %
|
||||
</td>
|
||||
<td>
|
||||
RSS:${h.format_byte_size_binary(mem.rss)}
|
||||
<% mem_sum += mem.rss %>
|
||||
</td>
|
||||
<td>
|
||||
VMS:${h.format_byte_size_binary(mem.vms)}
|
||||
</td>
|
||||
<td>
|
||||
AGE: ${h.age_component(h.time_to_utcdatetime(proc_child.create_time()))}
|
||||
</td>
|
||||
<td>
|
||||
<a href="#restartProcess" onclick="restart(this, ${proc_child.pid});return false">
|
||||
restart
|
||||
</a>
|
||||
</td>
|
||||
</tr>
|
||||
% endfor
|
||||
<tr>
|
||||
<td colspan="2"><code>| total processes: ${len(children)}</code></td>
|
||||
<td></td>
|
||||
<td><strong>RSS:${h.format_byte_size_binary(mem_sum)}</strong></td>
|
||||
<td></td>
|
||||
</tr>
|
||||
<tr><td> <code> -- </code> </td></tr>
|
||||
|
||||
% endif
|
||||
% endfor
|
||||
</table>
|
||||
Loading…
Add table
Add a link
Reference in a new issue