Skip to content

Commit 69f29b2

Browse files
committed
清理一些无效的代码
1 parent de0fc08 commit 69f29b2

File tree

8 files changed

+28
-119
lines changed

8 files changed

+28
-119
lines changed

app/config/config.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
'host' => '192.168.1.229',
88
'username' => 'root',
99
'password' => 'lala123',
10-
'dbname' => 'supervisor',
10+
'dbname' => 'supervisor-dashboard',
1111
'charset' => 'utf8mb4',
1212
],
1313
'application' => [

app/controller/ControllerSupervisorBase.php

-43
Original file line numberDiff line numberDiff line change
@@ -52,49 +52,6 @@ public function initialize()
5252
}
5353
}
5454

55-
/**
56-
* @link https://stackoverflow.com/questions/16941456/adding-a-php-anonymous-function-to-an-object
57-
* @param $callback
58-
*/
59-
protected function setCallback($callback)
60-
{
61-
$this->callback = $callback;
62-
}
63-
64-
protected function invoke($timeout = 10)
65-
{
66-
$exception = null;
67-
for ($i = 1; $i <= $timeout * 2; $i++)
68-
{
69-
try
70-
{
71-
call_user_func($this->callback);
72-
$exception = null;
73-
break;
74-
}
75-
catch (Exception $e)
76-
{
77-
$exception = $e;
78-
usleep(500000);
79-
}
80-
}
81-
82-
if ($exception)
83-
{
84-
throw $exception;
85-
}
86-
}
87-
88-
protected function redirectToIndex()
89-
{
90-
return $this->response->redirect(self::getIndexUrl());
91-
}
92-
93-
protected function getIndexUrl()
94-
{
95-
return "/server/{$this->server->id}/process?ip={$this->server->ip}&port={$this->server->port}";
96-
}
97-
9855
protected function formatMessage($message)
9956
{
10057
return "<strong>{$message}</strong>\n请刷新页面查看进度";

app/controller/SupervisorController.php

+8-28
Original file line numberDiff line numberDiff line change
@@ -5,36 +5,17 @@ class SupervisorController extends ControllerSupervisorBase
55
{
66
public function readLogAction()
77
{
8-
$callback = function ()
9-
{
10-
// 只看前面 1M 的日志
11-
$log = $log = $this->supervisor->readLog(-1024 * 1024, 0);
12-
$this->view->log = $log;
13-
};
14-
$this->setCallback($callback);
15-
$this->invoke();
8+
$log = $this->supervisor->readLog(-1024 * 1024, 0);
9+
$this->view->log = $log;
1610

1711
$this->view->disableLevel([
1812
View::LEVEL_LAYOUT => true,
1913
]);
20-
21-
$this->view->setTemplateBefore('readLog');
22-
23-
if ($this->isPjax())
24-
{
25-
$this->view->setRenderLevel(View::LEVEL_ACTION_VIEW);
26-
}
2714
}
2815

2916
public function clearLogAction()
3017
{
31-
$result = [];
32-
$callback = function()
33-
{
34-
$this->supervisor->clearLog();
35-
};
36-
$this->setCallback($callback);
37-
$this->invoke();
18+
$this->supervisor->clearLog();
3819

3920
$result['state'] = 1;
4021
$result['message'] = "日志清理完成";
@@ -52,12 +33,11 @@ public function restartAction()
5233

5334
fastcgi_finish_request();
5435

55-
$callback = function ()
56-
{
57-
$this->supervisor->restart();
58-
};
59-
$this->setCallback($callback);
60-
$this->invoke();
36+
$this->supervisor->restart();
37+
38+
$this->view->setRenderLevel(
39+
View::LEVEL_NO_RENDER
40+
);
6141
}
6242
}
6343

app/view/layouts/readLog.volt

-23
This file was deleted.

app/view/layouts/supervisor-config.volt

-7
This file was deleted.

app/view/layouts/supervisor.volt

-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
{% include 'partials/nav.volt' %}
22

33
<div id="pjax-container">
4-
11111
54
{{ content() }}
65
</div>
76

app/view/process/nav.volt

+1-15
Original file line numberDiff line numberDiff line change
@@ -66,23 +66,9 @@ $(function() {
6666
var ini_editor = document.getElementById('ini');
6767

6868
if (ini_editor) {
69-
// code editor
70-
var editor = CodeMirror.fromTextArea(document.getElementById('ini'), {
71-
mode: "properties",
72-
lineNumbers: true,
73-
lineWrapping: true,
74-
indentUnit: 0,
75-
autoRefresh: true,
76-
automaticLayout: true
77-
});
78-
69+
var editor = CodeMirror.fromTextArea(document.getElementById('ini'));
7970
editor.setSize('100%', '100%');
8071

81-
editor.on('change',function(cMirror){
82-
cMirror.refresh();
83-
editor.setSize('100%', '100%');
84-
});
85-
8672
$('a[data-toggle="tab"]').on('shown.bs.tab', function (e) {
8773
editor.refresh();
8874
});

app/view/supervisor/readLog.volt

+18-1
Original file line numberDiff line numberDiff line change
@@ -1 +1,18 @@
1-
{{ log | escape | default("没有任何日志记录") }}
1+
<nav class="navbar navbar-default navbar-fixed-top">
2+
<div class="container-fluid">
3+
<div class="navbar-header">
4+
<button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#bs-example-navbar-collapse-3" aria-expanded="false">
5+
<span class="sr-only">Toggle navigation</span>
6+
<span class="icon-bar"></span>
7+
<span class="icon-bar"></span>
8+
<span class="icon-bar"></span>
9+
</button>
10+
<a class="navbar-brand" href="">Supervisor 服务日志</a>
11+
</div>
12+
<div class="collapse navbar-collapse navbar-right">
13+
14+
</div>
15+
</div>
16+
</nav>
17+
18+
<samp id="log">{{ log | escape | default("没有任何日志记录") }}</samp>

0 commit comments

Comments
 (0)