2
0
mirror of https://github.com/acepanel/panel.git synced 2026-02-04 18:27:13 +08:00

特性:发布 20221130 版本

This commit is contained in:
耗子
2022-11-30 22:15:32 +08:00
parent 699562d504
commit 329f58da4b
24 changed files with 334 additions and 254 deletions

View File

@@ -2,7 +2,7 @@
/**
* Name: OpenResty插件控制器
* Author:耗子
* Date: 2022-11-21
* Date: 2022-11-30
*/
namespace Plugins\Openresty\Controllers;
@@ -11,15 +11,16 @@ namespace Plugins\Openresty\Controllers;
use App\Http\Controllers\Controller;
// HTTP
use Illuminate\Http\JsonResponse;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Http;
use Illuminate\Support\Facades\Request;
// Filesystem
use Illuminate\Filesystem\Filesystem;
class OpenrestyController extends Controller
{
public function status()
public function status(): JsonResponse
{
$command = 'systemctl status nginx';
$result = shell_exec($command);
@@ -35,7 +36,7 @@ class OpenrestyController extends Controller
return response()->json($res);
}
public function restart()
public function restart(): JsonResponse
{
$command = 'nginx -t 2>&1';
$result = shell_exec($command);
@@ -50,15 +51,12 @@ class OpenrestyController extends Controller
}
$command2 = 'systemctl restart nginx';
$result2 = shell_exec($command2);
if (str_contains($result2, 'done')) {
$res['data'] = 'OpenResty已重启';
return response()->json($res);
}
shell_exec($command2);
$res['data'] = 'OpenResty已重启';
return response()->json($res);
}
public function reload()
public function reload(): JsonResponse
{
$command = 'nginx -t 2>&1';
$result = shell_exec($command);
@@ -72,17 +70,12 @@ class OpenrestyController extends Controller
}
$command2 = 'systemctl reload nginx';
$result2 = shell_exec($command2);
if (str_contains($result2, 'done')) {
$res['data'] = 'OpenResty已重载';
} else {
$res['msg'] = 'error';
$res['data'] = 'OpenResty重载失败';
}
shell_exec($command2);
$res['data'] = 'OpenResty已重载';
return response()->json($res);
}
public function getConfig()
public function getConfig(): JsonResponse
{
$res['code'] = 0;
$res['msg'] = 'success';
@@ -90,12 +83,12 @@ class OpenrestyController extends Controller
return response()->json($res);
}
public function saveConfig()
public function saveConfig(Request $request): JsonResponse
{
$res['code'] = 0;
$res['msg'] = 'success';
// 获取配置内容
$config = Request::post('config');
$config = $request->input('config');
// 备份一份旧配置
$old_config = file_get_contents('/www/server/nginx/conf/nginx.conf');
// 写入配置
@@ -118,7 +111,7 @@ class OpenrestyController extends Controller
}
}
public function load()
public function load(): JsonResponse
{
$raw_status = HTTP::get('http://127.0.0.1/nginx_status')->body();
@@ -158,7 +151,7 @@ class OpenrestyController extends Controller
return response()->json($res);
}
public function errorLog()
public function errorLog(): JsonResponse
{
$res['code'] = 0;
$res['msg'] = 'success';
@@ -170,7 +163,7 @@ class OpenrestyController extends Controller
return response()->json($res);
}
public function cleanErrorLog()
public function cleanErrorLog(): JsonResponse
{
$res['code'] = 0;
$res['msg'] = 'success';

View File

@@ -1,5 +1,5 @@
{
"name": "OpenResty-1.21.4",
"name": "OpenResty",
"slug": "openresty",
"version": "1.21.4.1"
}

View File

@@ -1,7 +1,7 @@
<!--
Name: Openresty管理器
Author: 耗子
Date: 2022-11-21
Date: 2022-11-30
-->
<title>OpenResty</title>
<div class="layui-fluid" id="component-tabs">
@@ -96,7 +96,8 @@ Date: 2022-11-21
console.log('耗子Linux面板OpenResty错误日志获取失败接口返回' + result);
$('#openresty-error-log').text('OpenResty错误日志获取失败请刷新重试');
code({
title: 'error.log'
elem: '#openresty-error-log'
, title: 'error.log'
, encode: true
, about: false
@@ -105,7 +106,8 @@ Date: 2022-11-21
}
$('#openresty-error-log').text(result.data);
code({
title: 'error.log'
elem: '#openresty-error-log'
, title: 'error.log'
, encode: true
, about: false
@@ -201,8 +203,8 @@ Date: 2022-11-21
layer.alert(result.data);
return false;
}
layer.alert('OpenResty重启成功');
admin.events.refresh();
layer.alert('OpenResty重启成功');
}
, error: function (xhr, status, error) {
console.log('耗子Linux面板ajax请求出错错误' + error)