업데이트 서버 코드 추가
- VersionGit 양식 변경 - 서버 입구 버전 표기 - FileTail 추가 Vscode에서 che, kwe, pwe, twe 무시
This commit is contained in:
Vendored
+9
-1
@@ -7,10 +7,18 @@
|
||||
"**/.DS_Store": true,
|
||||
"**/logs/*.txt": true,
|
||||
"**/session/sess*":true,
|
||||
"/che":true,
|
||||
"/kwe":true,
|
||||
"/pwe":true,
|
||||
"/twe":true,
|
||||
|
||||
},
|
||||
"search.exclude": {
|
||||
"e_lib/*":true,
|
||||
"vendor/*":true
|
||||
"vendor/*":true,
|
||||
"/che":true,
|
||||
"/kwe":true,
|
||||
"/pwe":true,
|
||||
"/twe":true,
|
||||
},
|
||||
}
|
||||
@@ -5,4 +5,5 @@ class VersionGit{
|
||||
public static $version = '_tK_verionGit_';
|
||||
|
||||
private function __construct(){}
|
||||
}
|
||||
}
|
||||
//{"version":"_tK_verionGit_"}
|
||||
|
||||
@@ -17,6 +17,8 @@ $result = [];
|
||||
$server = [];
|
||||
|
||||
|
||||
$rootServer = end(AppConf::getList())->getShortName();
|
||||
|
||||
foreach (AppConf::getList() as $setting) {
|
||||
$serverColor = $setting->getColor();
|
||||
$serverKorName = $setting->getKorName();
|
||||
@@ -28,18 +30,24 @@ foreach (AppConf::getList() as $setting) {
|
||||
$state = [
|
||||
'valid'=>false,
|
||||
'run'=>false,
|
||||
'installed'=>false,
|
||||
'version'=>$setting->getVersion(),
|
||||
'reason'=>'디렉토리 없음'
|
||||
];
|
||||
} elseif (!file_exists($serverPath.'/index.php')) {
|
||||
$state = [
|
||||
'valid'=>false,
|
||||
'run'=>false,
|
||||
'installed'=>false,
|
||||
'version'=>$setting->getVersion(),
|
||||
'reason'=>'index.php 없음'
|
||||
];
|
||||
} elseif (!$setting->isExists()) {
|
||||
$state = [
|
||||
'valid'=>false,
|
||||
'run'=>false,
|
||||
'installed'=>true,
|
||||
'version'=>$setting->getVersion(),
|
||||
'reason'=>'설정 파일 없음'
|
||||
];
|
||||
} elseif (!$setting->isRunning()) {
|
||||
@@ -47,6 +55,8 @@ foreach (AppConf::getList() as $setting) {
|
||||
$state = [
|
||||
'valid'=>true,
|
||||
'run'=>false,
|
||||
'installed'=>true,
|
||||
'version'=>$setting->getVersion(),
|
||||
'reason'=>'폐쇄됨'
|
||||
];
|
||||
} else {
|
||||
@@ -54,6 +64,8 @@ foreach (AppConf::getList() as $setting) {
|
||||
$state = [
|
||||
'valid'=>true,
|
||||
'run'=>true,
|
||||
'installed'=>true,
|
||||
'version'=>$setting->getVersion(),
|
||||
'reason'=>'운영중'
|
||||
];
|
||||
}
|
||||
@@ -62,6 +74,7 @@ foreach (AppConf::getList() as $setting) {
|
||||
'name' => $serverDir,
|
||||
'korName' => $serverKorName,
|
||||
'color' => $serverColor,
|
||||
'isRoot' => $serverDir == $rootServer
|
||||
]);
|
||||
$server[] = $state;
|
||||
}
|
||||
|
||||
@@ -1,19 +1,21 @@
|
||||
<table id="server_admin_table">
|
||||
<caption class="bg2 section_title with_border">서 버 관 리</caption>
|
||||
<colgroup>
|
||||
<col style="width:80px;">
|
||||
<col style="width:65px;">
|
||||
<col style="width:135px;">
|
||||
<col>
|
||||
<col style="width:50px;"><!--폐쇄-->
|
||||
<col style="width:50px;"><!--오픈-->
|
||||
<col style="width:50px;"><!--리셋-->
|
||||
<col style="width:45px;"><!--폐쇄-->
|
||||
<col style="width:45px;"><!--오픈-->
|
||||
<col style="width:45px;"><!--리셋-->
|
||||
<col style="width:70px;"><!--하드리셋-->
|
||||
<col style="width:100px;"><!--폐쇄중 로그인-->
|
||||
<col style="width:70px;"><!--서버119-->
|
||||
<col style="width:65px;"><!--서버119-->
|
||||
<col style="width:70px;"><!--업데이트-->
|
||||
</colgroup>
|
||||
<thead>
|
||||
<th class="bg1">서버</th>
|
||||
<th class="bg1">상태</th>
|
||||
<th class="bg1">버전</th>
|
||||
<th class="bg1" colspan="7">명령 선택</th>
|
||||
</thead>
|
||||
<tbody id="server_admin_list">
|
||||
|
||||
@@ -148,6 +148,7 @@ $result = Util::generateFileUsingSimpleTemplate(
|
||||
);
|
||||
|
||||
Json::die([
|
||||
'server'=>$server,
|
||||
'result'=>true,
|
||||
'version'=>$version
|
||||
]);
|
||||
+50
-3
@@ -1,18 +1,62 @@
|
||||
|
||||
var serverAdminTemplate = '\
|
||||
<tr class="bg0" data-server_name="<%name%>">\
|
||||
<tr class="bg0" data-server_name="<%name%>" data-is_root="<%isRoot%>">\
|
||||
<th style="color:<%color%>;"><%korName%>(<%name%>)</th>\
|
||||
<td><%status%></td>\
|
||||
<td><%version%></td>\
|
||||
<td><button class="valid_if_set with_border obj_fill" onclick="modifyServerStatus(this, \'close\');">폐쇄</button></td>\
|
||||
<td><button class="valid_if_set with_border obj_fill" onclick="modifyServerStatus(this, \'open\');">오픈</button></td>\
|
||||
<td><a class="just_link" href="../<%name%>/install.php"><button class="valid_if_set with_border obj_fill">리셋</button></a></td>\
|
||||
<td><a class="just_link" href="../<%name%>/install_db.php"><button class="valid_if_set only_admin with_border obj_fill">하드리셋</button></a></td>\
|
||||
<td><a class="just_link" href="../<%name%>/install_db.php"><button class="valid_if_installed only_admin with_border obj_fill">하드리셋</button></a></td>\
|
||||
<td><button class="valid_if_set with_border obj_fill" onclick="Entrance_AdminClosedLogin(this);">폐쇄중 로그인</button></td>\
|
||||
<td><button class="valid_if_set with_border obj_fill" onclick="Entrance_AdminOpen119(this);">서버119</button></td>\
|
||||
<td><button class="only_admin with_border obj_fill" onclick="Entrance_AdminOpen119(this);">업데이트</button></td>\
|
||||
<td><button class="only_admin with_border obj_fill" onclick="serverUpdate(this);">업데이트</button></td>\
|
||||
</tr>\
|
||||
';
|
||||
|
||||
function serverUpdate(caller){
|
||||
var $caller = $(caller);
|
||||
var $tr = $caller.parents('tr');
|
||||
var server = $tr.data('server_name');
|
||||
var isRoot = $tr.data('is_root');
|
||||
|
||||
var target = 'master';
|
||||
|
||||
if(typeof isRoot !== 'boolean'){
|
||||
isRoot = (isRoot != 'false');
|
||||
};
|
||||
|
||||
if(isRoot){
|
||||
if(!confirm('서버 라이브러리, 루트 서버에 대해 git pull을 실행합니다.')){
|
||||
return;
|
||||
}
|
||||
}
|
||||
else{
|
||||
target = prompt('가져올 git tree-ish 명을 입력해주세요.', target)
|
||||
if(!target){
|
||||
return;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
$.ajax({
|
||||
type:'post',
|
||||
url:'../j_updateServer.php',
|
||||
dataType:'json',
|
||||
data:{
|
||||
server: server,
|
||||
target: target
|
||||
}
|
||||
}).then(function(response) {
|
||||
if(response.result) {
|
||||
alert('{0} 서버가 {1} 버전으로 업데이트 되었습니다.'.format(response.server, response.version));
|
||||
location.reload();
|
||||
} else {
|
||||
alert(response.reason);
|
||||
}
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
function drawServerAdminList(serverList){
|
||||
var $table = $('#server_admin_list');
|
||||
@@ -35,6 +79,9 @@ function drawServerAdminList(serverList){
|
||||
if(!server.valid){
|
||||
$tr.find('.valid_if_set').css('background','#333333').prop('disabled', true);
|
||||
}
|
||||
if(!server.installed){
|
||||
$tr.find('.valid_if_installed').css('background','#333333').prop('disabled', true);
|
||||
}
|
||||
});
|
||||
if(serverList.grade == 5){
|
||||
$table.find('.only_admin').css('background','#333333').prop('disabled', true);
|
||||
|
||||
@@ -0,0 +1,6 @@
|
||||
<?php
|
||||
namespace sammo;
|
||||
|
||||
class FileTail extends \PhpExtended\Tail\Tail{
|
||||
|
||||
};
|
||||
+2
-5
@@ -25,7 +25,7 @@ class Json{
|
||||
return json_decode($value, true);
|
||||
}
|
||||
|
||||
public static function die($value, $flag = NO_CACHE){
|
||||
public static function die($value, $flag = self::NO_CACHE){
|
||||
//NOTE: REST 형식에 맞게, ok(), fail()로 쪼개는게 낫지 않을까 생각해봄.
|
||||
if($flag & static::NO_CACHE){
|
||||
WebUtil::setHeaderNoCache();
|
||||
@@ -33,9 +33,6 @@ class Json{
|
||||
|
||||
header('Content-Type: application/json');
|
||||
|
||||
echo Json::encode($value, $flag);
|
||||
if($die){
|
||||
die();
|
||||
}
|
||||
die(Json::encode($value, $flag));
|
||||
}
|
||||
}
|
||||
@@ -5,17 +5,20 @@ class Setting {
|
||||
private $basepath;
|
||||
private $settingFile;
|
||||
private $htaccessFile;
|
||||
private $versionFile;
|
||||
private $exist = false;
|
||||
private $running = false;
|
||||
|
||||
private $shortName;
|
||||
private $korName;
|
||||
private $color;
|
||||
private $version = null;
|
||||
|
||||
public function __construct(string $basepath, string $korName, string $color, string $name=null) {
|
||||
$this->basepath = $basepath;
|
||||
$this->settingFile = realpath($basepath.'/d_setting/DB.php');
|
||||
$this->htaccessFile = realpath($basepath.'/.htaccess');
|
||||
$this->versionFile = realpath($basepath.'/d_setting/VersionGit.php');
|
||||
|
||||
$this->korName = $korName;
|
||||
$this->color = $color;
|
||||
@@ -62,6 +65,30 @@ class Setting {
|
||||
public function getSettingFile() {
|
||||
return $this->settingFile;
|
||||
}
|
||||
|
||||
public function getVersion(){
|
||||
if($this->version !== null){
|
||||
return $this->version;
|
||||
}
|
||||
|
||||
if(!file_exists($this->versionFile)){
|
||||
$this->version = 'noVersionFile';
|
||||
return $this->version;
|
||||
}
|
||||
|
||||
$tail = new FileTail($this->versionFile);
|
||||
$version = 'noVersionJson';
|
||||
foreach ($tail->smart(5, 100, true) as $line) {
|
||||
if(Util::starts_with($line, '//{')){
|
||||
$version = Json::decode(substr($line, 2));
|
||||
$version = Util::array_get($version['version'], 'noVersionValue');
|
||||
break;
|
||||
}
|
||||
}
|
||||
$this->version = $version;
|
||||
return $version;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user