<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>uWSGI {{uwsgi.version}} Control Center</title>

<link href="{{ url_for('static', filename='css/custom-theme/jquery-ui-1.8.14.custom.css') }}" rel="stylesheet" type="text/css"/>
<script src="{{ url_for('static', filename='js/jquery-1.5.1.min.js') }}"></script>
<script src="{{ url_for('static', filename='js/jquery-ui-1.8.14.custom.min.js') }}"></script>

<style type="text/css"> 
body {
  background: #fff;
  font-family: 'Lucida Sans','Arial',sans;
  font-size: 12px;
  line-height: 20px;
  margin: 0px;
  padding: 0px;
}

h1{
    border-bottom: 2px solid #B0D534;
    font-size: 24px;
    line-height: 24px;
    margin-bottom: 5px;
    padding: 10px;
    background-color: #000;    
    color: #fff;
    margin-top: 0;
    font-weight: normal;
}

h3{
    font-size: 14px;
    margin-left: 10px;  
    color: #666;
    font-weight: normal;
    margin-bottom: 10px;
    margin-right: 10px;
    border-bottom: 2px solid #B0D534;
}

.small{
    font-size: 12px;
    color: #999;
    margin-right:10px;
    margin-left:-5px;
}



.info{
    margin-left: 10px;
    padding-left: 20px;
    margin-bottom: 40px;
}

input{
    margin: 10px 0px;
}

input[type=submit]{
    border: none;
    padding: 3px 10px;
    color: #fff;
    background-color: #444444;
    background-image: -moz-linear-gradient(top, #444444, #999999); /* FF3.6 */
    background-image: -webkit-gradient(linear,left top,left bottom,color-stop(0, #444444),color-stop(1, #999999)); /* Saf4+, Chrome */
    -ms-filter: "progid:DXImageTransform.Microsoft.gradient(startColorStr='#444444', EndColorStr='#999999')"; /* IE8 */
    
    -moz-border-radius: 7px; /* FF1+ */
    -webkit-border-radius: 7px; /* Saf3-4 */
    border-radius: 7px; /* Opera 10.5, IE 9, Saf5, Chrome */
    
    -moz-box-shadow: 0px 0px 1px #000; /* FF3.5+ */
    -webkit-box-shadow: 0px 0px 1px #000; /* Saf3.0+, Chrome */
    box-shadow: 0px 0px 1px #000; /* Opera 10.5, IE 9 */
    
    text-shadow: 0px 1px 1px #000;
    
}

input[type=text].wide{
    width: 350px;
}

table{
    border-collapse:collapse;
    padding: 5px;
}

td{
    border: 1px solid #999;
    text-align: center;
    padding: 0px 5px;
    border-right:1px solid #999;
    border-left:1px solid #999;
    
}

.odd {
    background-color:#fff;
}

.even{
    background-color:#eeeeee;
}

tr.last{
    font-size: bold;
    background: #222;
    color: #fff;
}

.anchor{
    text-align: right;
    margin-right: 10px;
}

.flash{
    background-color: #de211f;
    color: #fff;
    margin: 10px;
    padding: 5px;
}

a, a:link, a:focus, a:active, a:visited{
    font-size: 10px;
    color: #999;
    text-decoration: none;
    border-bottom: 1px dotted #999;
}

a:hover{
    color: #000;
}

</style>

<script>

$(document).ready(function() {

	$('#rpc_tabs').tabs();

	$("input#rpc_func").autocomplete({
		source: [
				{% for r in uwsgi.rpc_list() %}
					"{{r}}",
				{% endfor %}
			]
	});

	$('#rpc_form').submit(function() {
		$.post('{{url_for('rpc')}}', { node: $('[name=node]').val(), func: $('[name=func]').val(), args: $('[name=args]').val()}, function(data) {
			$('#dialog-modal').html(data);
			$('#dialog-modal').attr('title', 'RPC "hello" returned:');
			$('#dialog-modal').dialog({
				modal: true
			});
		});
		return false;
	});
});

</script>
</head>

<body>

<div id="dialog-modal">
</div>

<a name="top"></a>
<h1>uWSGI <span class="small">{{uwsgi.version}}</span> Control Center</h1>
<div class="anchor">
<a href="#information">information</a> | <a href="#options">options</a> | <a href="#logs">logs</a> | <a href="#signals">signals</a> | <a href="#workers">workers</a> | <a href="#applications">applications</a> | <a href="#rpc">rpc</a> {% if uwsgi.cluster() %}| <a href="#cluster">cluster</a>{% endif %}
</div>

{% with messages = get_flashed_messages() %}
	{% if messages %}
		<div class="flash">
		        <ul>
    			{% for message in messages %}
      				<li>{{ message }}</li>
    			{% endfor %}
    			</ul>
		</div>
	{% endif %}
{% endwith %}

<a name="information"></a>
<h3>Information</h3>
<div class="info">
<b>hostname:</b> {{ hostname }}<br/>
<b>nodename:</b> {{uwsgi.cluster_node_name()}}<br/>
<b>uid:</b> {{ uid }}<br/>
<b>gid:</b> {{ gid }}<br/>
<b>cwd:</b> {{ cwd }}<br/>
<b>mode:</b> {{uwsgi.mode}}<br/>
<b>loop:</b> {{uwsgi.loop}}<br/>
<b>started_on:</b> {{uwsgi.started_on|unixtime}}<br/>
<b>workers:</b> {{uwsgi.numproc}}<br/>
<b>cores:</b> {{ uwsgi.cores }}<br/>
<b>masterpid:</b> {{uwsgi.masterpid()}}<br/>
<b>cluster:</b> {{uwsgi.cluster()}}<br/>
{% if uwsgi.opt['spooler'] %}
<b>spooler pid:</b> {{uwsgi.spooler_pid()}}<br/>
{% endif %}

{% if uwsgi.has_threads == 1 %}
<b>--- threads enabled ---</b><br/>
{% endif %}

    <div class="anchor">
    <a href="#top">back to top</a>
    </div>

</div>


<a name="options"></a>
<h3>Options</h3>
<div class="info">
{% for k in uwsgi.opt.keys() %}
	<b>{{k}}</b>: {{uwsgi.opt[k]}}<br/>
{% endfor %}

    <div class="anchor">
    <a href="#top">back to top</a>
    </div>

</div>

<a name="logs"></a>
<h3>Logs (size: {{ uwsgi.logsize() }} bytes)</h3>
<div class="info">
<form action="{{url_for('log')}}" method="POST">
	<input type="text" size="72" name="message" /> 
	<input type="submit" value="write message to the log" />
</form>

    <div class="anchor">
    <a href="#top">back to top</a>
    </div>

</div>

<a name="signals"></a>
<h3>Signals</h3>
<div class="info">
<form action="{{url_for('sig')}}" method="POST">
        <input type="text" size="3" name="signum" />
        <input type="submit" value="send uwsgi signal" />
</form>

    <div class="anchor">
    <a href="#top">back to top</a>
    </div>

</div>


<a name="workers"></a>
<h3>Workers</h3>
<div class="info">
<table width="600">
<tr>
    <th>#</th>
    <th>pid</th>
    <th>status</th>
    <th>requests</th>
    <th>exceptions</th>
    <th>signals</th>
    <th>running time</th>
    <th>avg response time</th>
{% if 'memory-report' in uwsgi.opt %}
    <th>rss</th>
    <th>vsz</th>
{% endif %}
    <th># respawn</th>
</tr>
{% for w in uwsgi.workers() %}
	<tr class="{{ loop.cycle('odd', 'even') }}">
		<td>{{w.id}}</td>
		<td>{{w.pid}}</td>
		<td>{{w.status}}</td>
		<td>{{w.requests}}</td>
		<td>{{w.exceptions}}</td>
		<td>{{w.signals}}</td>
		<td>{{w.running_time/1000}}</td>
		<td>{{w.avg_rt/1000}}</td>
{% if 'memory-report' in uwsgi.opt %}
		<td>{{(w.rss/1000/1000)|round(2,'floor')}}MB</td>
		<td>{{(w.vsz/1000/1000)|round(2,'floor')}}MB</td>
{% endif %}
		<td>{{w.respawn_count}}</td>
	</tr>
{% endfor %}
</table>
<br/>
    <div class="anchor">
    <a href="#top">back to top</a>
    </div>

</div>

<a name="applications"></a>
<h3>Applications</h3>
<div class="info">
{% for w in uwsgi.workers() %}
worker {{w.id}}
<table width="600">
<tr>
    <th>#</th>
    <th>modifier1</th>
    <th>mountpoint</th>
    <th>interpreter</th>
    <th>callable</th>
    <th>chdir</th>
    <th>requests</th>
    <th>exceptions</th>
</tr>
{% for app in w.apps %}
        <tr class="{{ loop.cycle('odd', 'even') }}">
                <td>{{app.id}}</td>
                <td>{{app.modifier1}}</td>
                <td>{{app.mountpoint}}</td>
                <td>{{app.interpreter}}</td>
                <td>{{app.callable}}</td>
                <td>{{app.chdir}}</td>
                <td>{{app.requests}}</td>
                <td>{{app.exceptions}}</td>
        </tr>
{% endfor %}
</table>
<br/><br/>
{% endfor %}
<br/>
    <div class="anchor">
    <a href="#top">back to top</a>
    </div>

</div>


<a name="rpc"></a>
<div id="rpc_tabs" class="info">

<ul>
	<li><a href="#rpc_tabs-1">RPC</a></li>
	<li><a href="#rpc_tabs-2">RPC List</a></li>
</ul>


<div id="rpc_tabs-1">
<form id="rpc_form">
<b>node address (leave empty for local rpc):</b> <input type="text" name="node" /> <b>function:</b> <input id="rpc_func" type="text" name="func" /> <b>args (separated by space, optional):</b> <input type="text" name="args" /> <input type="submit" value="call" /><br/>
</form>
</div>

<div id="rpc_tabs-2">
	<ul>
		{% for r in uwsgi.rpc_list() %}
			<li>{{ r }}</li>
		{% endfor %}
	</ul>
</div>

</div>

<br/>
    <div class="anchor">
    <a href="#top">back to top</a>
    </div>



{% if uwsgi.cluster() %}
<a name="cluster"></a>
<h3>Cluster nodes</h3>
<div class="info">
<i>best is <b>{{ uwsgi.cluster_best_node() }}</b></i><br/><br/>
<table>
<tr>
    <th>hostname</th>
    <th>socket</th>
</tr>
{% for ucn in uwsgi.cluster_nodes() %}
	<tr class="{{ loop.cycle('odd', 'even') }}">
		<td>{{ uwsgi.cluster_node_name(ucn) }}</td>
		<td>{{ ucn }}</td>
		<form method="POST">
		<td>
			<input type="hidden" name="node" value="{{ucn}}"/>
			<input type="text" size="3" name="signal" /> 
			<input type="submit" value="send uwsgi signal" />
		</td>
		</form>

		<form method="POST">
		<td>
			<input type="hidden" name="node" value="{{ucn}}"/>
			<input type="text" class="wide" size="72" name="message" /> 
			<input type="submit" value="send log message" />
		</td>
		</form>

		<form method="POST">
		<td>
			<input type="hidden" name="node" value="{{ucn}}"/>
			<input type="submit" value="reload node" />
		</td>
		</form>
	</tr>
{% endfor %}
    <tr class="last">
    <td colspan="2">All cluster nodes</td>
    <td>
        <form method="POST">
    	    <input type="text" size="3" name="signal" />
            <input type="submit" value="send uwsgi signal" />
        </form>
    </td>
    <td>
        <form method="POST">
        	<input type="text" class="wide" size="72" name="message" /> 
        	<input type="submit" value="send log message" />
        </form>
    </td>
    <td>
        <form method="POST">
    	    <input type="submit" value="reload cluster" />
        </form>
    </td>
    </tr>

</table>
<br/>
    <div class="anchor">
    <a href="#top">back to top</a>
    </div>

</div>

{% endif %}
</body>
</html>
