Commit 9da15d4d32b6bad76641d7d3f5b2d8b8fadc728e

Authored by Adhidarma Hadiwinoto
1 parent 3cb69228e8
Exists in master

pause, resume, terminate

Showing 4 changed files with 109 additions and 2 deletions Side-by-side Diff

... ... @@ -95,8 +95,9 @@ function submitResume(req, res) {
95 95 }
96 96  
97 97 function submitTerminate(req, res) {
98   - res.end('Terminating....');
99   - process.exit();
  98 + res.end('Terminating....', function() {
  99 + setTimeout(process.exit, 2 * 1000);
  100 + });
100 101 }
101 102  
102 103 function submitConfigEdit(req, res) {
... ... @@ -179,6 +180,14 @@ function renderConfigAskDelete(req, res) {
179 180 });
180 181 }
181 182  
  183 +function renderAskTerminate(req, res) {
  184 + res.render('ask.terminate.html', {
  185 + gateway_name: config.globals.gateway_name,
  186 + title: 'Konfirmasi Terminasi'
  187 + });
  188 +}
  189 +
  190 +
182 191 function renderRuntimeInfo(req, res) {
183 192 var template = "runtime-info.html";
184 193  
... ... @@ -318,6 +327,7 @@ function createServer() {
318 327 app.get('/pause', loggedIn, submitPause);
319 328 app.get('/resume', loggedIn, submitResume);
320 329 app.get('/terminate', loggedIn, submitTerminate);
  330 + app.get('/ask-terminate', loggedIn, renderAskTerminate);
321 331  
322 332 app.get('/runtime-info', loggedIn, renderRuntimeInfo);
323 333  
views/ask.terminate.html
... ... @@ -0,0 +1,15 @@
  1 +{% extends "layout-with-topbar.html" %}
  2 +
  3 +{% block content %}
  4 +
  5 +Yakin ingin terminasi gateway?
  6 +
  7 +<br/><br/>
  8 +
  9 +<a class="btn btn-danger" href="/terminate" role="button">
  10 + Terminasi</a>
  11 +
  12 +<a class="btn btn-default" href="/dashboard" role="button">
  13 + Batal</a>
  14 +
  15 +{% endblock %}
views/dashboard.html
... ... @@ -0,0 +1,51 @@
  1 +{% extends "layout-with-topbar.html" %}
  2 +
  3 +{% block content %}
  4 +
  5 +<div id="paused-or-running" class="panel panel-default">
  6 +
  7 + <div class="panel-heading">
  8 + <h3>Pause and Resume</h3>
  9 + </div>
  10 +
  11 + <div class="panel-body">
  12 + {% if config.globals.pause %}
  13 +
  14 +
  15 + <p> System paused. Click the button to resume it.</p>
  16 +
  17 + <p>
  18 + <a href="/resume" class="btn btn-primary">Resume</a>
  19 + </p>
  20 +
  21 +
  22 + {% else %}
  23 +
  24 + <p> System is running. Click the button to pause it</p>
  25 +
  26 + <div class="pull-right">
  27 + <a href="/pause" class="btn btn-primary">Pause</a>
  28 + </div>
  29 +
  30 + {% endif %}
  31 + </div>
  32 +
  33 +</div>
  34 +
  35 +<div id="terminate" class="panel panel-default">
  36 +
  37 + <div class="panel-heading">
  38 + <h3>Process Termination</h3>
  39 + </div>
  40 +
  41 + <div class="panel-body">
  42 + <p>Click the button to terminate (or restart) the gateway.</p>
  43 +
  44 + <div class="pull-right">
  45 + <a href="/ask-terminate" class="btn btn-danger">Terminate / Restart</a>
  46 + </div>
  47 + </div>
  48 +
  49 +</div>
  50 +
  51 +{% endblock %}
views/runtime-info.html
... ... @@ -0,0 +1,31 @@
  1 +{% extends "layout-with-topbar.html" %}
  2 +
  3 +{% block content %}
  4 +
  5 +<p>
  6 + Process uptime: {{ uptime }} seconds
  7 +</p>
  8 +
  9 +<h2 id="matrix">The Matrix</h2>
  10 +<pre>{{ matrix }}</pre>
  11 +
  12 +<h2 id="pendings">Pending Transactions</h2>
  13 +<pre>{{ pendings }}</pre>
  14 +
  15 +
  16 +<h2 id="config">Config</h2>
  17 +<pre>{{ config }}</pre>
  18 +
  19 +<h2 id="memory">Memory Usage</h2>
  20 +<pre>{{ memory_usage }}</pre>
  21 +
  22 +<h2 id="nodejs_versions">Node.js Versions</h2>
  23 +<pre>{{ nodejs_versions }}</pre>
  24 +
  25 +<h2 id="os_info">OS</h2>
  26 +<pre>{{ os_info }}</pre>
  27 +
  28 +<h2 id="net_iface">Network Interfaces</h2>
  29 +<pre>{{ net_ifaces }}</pre>
  30 +
  31 +{% endblock %}