mirror of https://github.com/midoks/mdserver-web
pull/109/head
parent
9bdc83a648
commit
6a6a1d2804
Before Width: | Height: | Size: 4.4 KiB |
@ -1,23 +0,0 @@ |
|||||||
<div class="bt-form"> |
|
||||||
<div class="bt-w-main"> |
|
||||||
<div class="bt-w-menu"> |
|
||||||
<p class="bgw" onclick="pluginService('go-fastdfs');">服务</p> |
|
||||||
<p onclick="pluginInitD('go-fastdfs');">自启动</p> |
|
||||||
<p onclick="pluginConfig('go-fastdfs');">配置文件</p> |
|
||||||
<p onclick="gfConfigSet()">重要配置查看</p> |
|
||||||
<p onclick="pluginLogs('go-fastdfs','','run_log');">运行日志</p> |
|
||||||
<p onclick="pluginLogs('go-fastdfs','','breakpoint_log');">断点日志</p> |
|
||||||
<p onclick="pRead()">说明</p> |
|
||||||
</div> |
|
||||||
<div class="bt-w-con pd15"> |
|
||||||
<div class="soft-man-con"></div> |
|
||||||
</div> |
|
||||||
</div> |
|
||||||
</div> |
|
||||||
|
|
||||||
<script type="text/javascript"> |
|
||||||
resetPluginWinWidth(700); |
|
||||||
$.getScript( "/plugins/file?name=go-fastdfs&f=js/fastdfs.js", function() { |
|
||||||
pluginService('go-fastdfs'); |
|
||||||
}); |
|
||||||
</script> |
|
@ -1,224 +0,0 @@ |
|||||||
# coding: utf-8 |
|
||||||
|
|
||||||
import time |
|
||||||
import random |
|
||||||
import os |
|
||||||
import json |
|
||||||
import re |
|
||||||
import sys |
|
||||||
import subprocess |
|
||||||
import threading |
|
||||||
|
|
||||||
sys.path.append(os.getcwd() + "/class/core") |
|
||||||
import mw |
|
||||||
|
|
||||||
app_debug = False |
|
||||||
if mw.isAppleSystem(): |
|
||||||
app_debug = True |
|
||||||
|
|
||||||
|
|
||||||
def getPluginName(): |
|
||||||
return 'go-fastdfs' |
|
||||||
|
|
||||||
|
|
||||||
def getPluginDir(): |
|
||||||
return mw.getPluginDir() + '/' + getPluginName() |
|
||||||
|
|
||||||
|
|
||||||
def getServerDir(): |
|
||||||
return mw.getServerDir() + '/' + getPluginName() |
|
||||||
|
|
||||||
|
|
||||||
def getInitDFile(): |
|
||||||
if app_debug: |
|
||||||
return '/tmp/' + getPluginName() |
|
||||||
return '/etc/init.d/' + getPluginName() |
|
||||||
|
|
||||||
|
|
||||||
def getInitDTpl(): |
|
||||||
return getPluginDir() + "/init.d/" + getPluginName() + ".tpl" |
|
||||||
|
|
||||||
|
|
||||||
def getLog(): |
|
||||||
return getServerDir() + "/log/fileserver.log" |
|
||||||
|
|
||||||
|
|
||||||
def gfBreakpointLog(): |
|
||||||
return getServerDir() + "/log/tusd.log" |
|
||||||
|
|
||||||
|
|
||||||
def getArgs(): |
|
||||||
args = sys.argv[2:] |
|
||||||
tmp = {} |
|
||||||
args_len = len(args) |
|
||||||
|
|
||||||
if args_len == 1: |
|
||||||
t = args[0].strip('{').strip('}') |
|
||||||
t = t.split(':') |
|
||||||
tmp[t[0]] = t[1] |
|
||||||
elif args_len > 1: |
|
||||||
for i in range(len(args)): |
|
||||||
t = args[i].split(':') |
|
||||||
tmp[t[0]] = t[1] |
|
||||||
|
|
||||||
return tmp |
|
||||||
|
|
||||||
|
|
||||||
def checkArgs(data, ck=[]): |
|
||||||
for i in range(len(ck)): |
|
||||||
if not ck[i] in data: |
|
||||||
return (False, mw.returnJson(False, '参数:(' + ck[i] + ')没有!')) |
|
||||||
return (True, mw.returnJson(True, 'ok')) |
|
||||||
|
|
||||||
|
|
||||||
def status(): |
|
||||||
pn = getPluginName() |
|
||||||
data = mw.execShell( |
|
||||||
"ps -ef|grep " + pn + " |grep -v grep |grep -v .jar | grep -v python | awk '{print $2}'") |
|
||||||
if data[0] == '': |
|
||||||
return 'stop' |
|
||||||
return 'start' |
|
||||||
|
|
||||||
|
|
||||||
def initDreplace(): |
|
||||||
|
|
||||||
file_tpl = getInitDTpl() |
|
||||||
service_path = os.path.dirname(os.getcwd()) |
|
||||||
|
|
||||||
initD_path = getServerDir() + '/init.d' |
|
||||||
if not os.path.exists(initD_path): |
|
||||||
os.mkdir(initD_path) |
|
||||||
|
|
||||||
file_bin = initD_path + '/' + getPluginName() |
|
||||||
if not os.path.exists(file_bin): |
|
||||||
content = mw.readFile(file_tpl) |
|
||||||
content = content.replace('{$SERVER_PATH}', service_path) |
|
||||||
mw.writeFile(file_bin, content) |
|
||||||
mw.execShell('chmod +x ' + file_bin) |
|
||||||
|
|
||||||
return file_bin |
|
||||||
|
|
||||||
|
|
||||||
def start(): |
|
||||||
file = initDreplace() |
|
||||||
data = mw.execShell(file + ' start') |
|
||||||
if data[1] == '': |
|
||||||
return 'ok' |
|
||||||
return 'fail' |
|
||||||
|
|
||||||
|
|
||||||
def stop(): |
|
||||||
file = initDreplace() |
|
||||||
data = mw.execShell(file + ' stop') |
|
||||||
if data[1] == '': |
|
||||||
return 'ok' |
|
||||||
return 'fail' |
|
||||||
|
|
||||||
|
|
||||||
def restart(): |
|
||||||
file = initDreplace() |
|
||||||
data = mw.execShell(file + ' restart') |
|
||||||
if data[1] == '': |
|
||||||
return 'ok' |
|
||||||
return 'fail' |
|
||||||
|
|
||||||
|
|
||||||
def reload(): |
|
||||||
file = initDreplace() |
|
||||||
data = mw.execShell(file + ' reload') |
|
||||||
if data[1] == '': |
|
||||||
return 'ok' |
|
||||||
return 'fail' |
|
||||||
|
|
||||||
|
|
||||||
def initdStatus(): |
|
||||||
initd_bin = getInitDFile() |
|
||||||
if os.path.exists(initd_bin): |
|
||||||
return 'ok' |
|
||||||
return 'fail' |
|
||||||
|
|
||||||
|
|
||||||
def initdInstall(): |
|
||||||
import shutil |
|
||||||
|
|
||||||
source_bin = initDreplace() |
|
||||||
initd_bin = getInitDFile() |
|
||||||
shutil.copyfile(source_bin, initd_bin) |
|
||||||
mw.execShell('chmod +x ' + initd_bin) |
|
||||||
|
|
||||||
if not app_debug: |
|
||||||
mw.execShell('chkconfig --add ' + getPluginName()) |
|
||||||
return 'ok' |
|
||||||
|
|
||||||
|
|
||||||
def initdUinstall(): |
|
||||||
if not app_debug: |
|
||||||
mw.execShell('chkconfig --del ' + getPluginName()) |
|
||||||
|
|
||||||
initd_bin = getInitDFile() |
|
||||||
|
|
||||||
if os.path.exists(initd_bin): |
|
||||||
os.remove(initd_bin) |
|
||||||
return 'ok' |
|
||||||
|
|
||||||
|
|
||||||
def gfConf(): |
|
||||||
return getServerDir() + "/conf/cfg.json" |
|
||||||
|
|
||||||
|
|
||||||
def gfConfSet(): |
|
||||||
gets = [ |
|
||||||
{'name': 'addr', 'type': -1, 'ps': '绑定端口'}, |
|
||||||
{'name': 'peer_id', 'type': -1, 'ps': '集群内唯一,请使用0-9的单字符'}, |
|
||||||
{'name': 'host', 'type': -1, 'ps': '本主机地址'}, |
|
||||||
{'name': 'group', 'type': -1, 'ps': '组号'}, |
|
||||||
{'name': 'support_group_manage', 'type': 0, 'ps': '是否支持按组(集群)管理'}, |
|
||||||
{'name': 'enable_merge_small_file', 'type': 0, 'ps': '是否合并小文件'}, |
|
||||||
{'name': 'refresh_interval', 'type': 1, 'ps': '重试同步失败文件的时间'}, |
|
||||||
{'name': 'rename_file', 'type': 0, 'ps': '是否自动重命名'}, |
|
||||||
{'name': 'enable_web_upload', 'type': 0, 'ps': '是否支持web上传,方便调试'}, |
|
||||||
{'name': 'enable_custom_path', 'type': 0, 'ps': '是否支持非日期路径'}, |
|
||||||
{'name': 'enable_migrate', 'type': 0, 'ps': '是否启用迁移'}, |
|
||||||
{'name': 'enable_cross_origin', 'type': 0, 'ps': '是否开启跨站访问'}, |
|
||||||
{'name': 'enable_tus', 'type': 0, 'ps': '是否开启断点续传'} |
|
||||||
] |
|
||||||
file = mw.readFile(gfConf()) |
|
||||||
data = json.loads(file) |
|
||||||
|
|
||||||
result = [] |
|
||||||
for g in gets: |
|
||||||
if g['name'] in data: |
|
||||||
g['value'] = data[g['name']] |
|
||||||
result.append(g) |
|
||||||
|
|
||||||
return mw.getJson(result) |
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__": |
|
||||||
func = sys.argv[1] |
|
||||||
if func == 'status': |
|
||||||
print(status()) |
|
||||||
elif func == 'start': |
|
||||||
print(start()) |
|
||||||
elif func == 'stop': |
|
||||||
print(stop()) |
|
||||||
elif func == 'restart': |
|
||||||
print(restart()) |
|
||||||
elif func == 'reload': |
|
||||||
print(reload()) |
|
||||||
elif func == 'initd_status': |
|
||||||
print(initdStatus()) |
|
||||||
elif func == 'initd_install': |
|
||||||
print(initdInstall()) |
|
||||||
elif func == 'initd_uninstall': |
|
||||||
print(initdUinstall()) |
|
||||||
elif func == 'run_log': |
|
||||||
print(getLog()) |
|
||||||
elif func == 'breakpoint_log': |
|
||||||
print(gfBreakpointLog()) |
|
||||||
elif func == 'conf': |
|
||||||
print(gfConf()) |
|
||||||
elif func == 'gf_conf_set': |
|
||||||
print(gfConfSet()) |
|
||||||
else: |
|
||||||
print('error') |
|
@ -1,16 +0,0 @@ |
|||||||
{ |
|
||||||
"id":10, |
|
||||||
"title":"go-fastdfs", |
|
||||||
"tip":"soft", |
|
||||||
"name":"go-fastdfs", |
|
||||||
"type":"软件", |
|
||||||
"ps":"一个基于http协议的分布式文件系统", |
|
||||||
"versions":"1.3.1", |
|
||||||
"shell":"install.sh", |
|
||||||
"checks":"server/go-fastdfs", |
|
||||||
"path": "server/go-fastdfs", |
|
||||||
"author":"midoks", |
|
||||||
"home":"https://github.com/sjqzhang/go-fastdfs", |
|
||||||
"date":"2019-08-02", |
|
||||||
"pid":"5" |
|
||||||
} |
|
@ -1,72 +0,0 @@ |
|||||||
#!/bin/bash |
|
||||||
# chkconfig: 2345 55 25 |
|
||||||
# description: go-fastdfs Cloud Service |
|
||||||
|
|
||||||
### BEGIN INIT INFO |
|
||||||
# Provides: bt |
|
||||||
# Required-Start: $all |
|
||||||
# Required-Stop: $all |
|
||||||
# Default-Start: 2 3 4 5 |
|
||||||
# Default-Stop: 0 1 6 |
|
||||||
# Short-Description: starts go-fastdfs |
|
||||||
# Description: starts the go-fastdfs |
|
||||||
### END INIT INFO |
|
||||||
|
|
||||||
|
|
||||||
PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:~/bin |
|
||||||
|
|
||||||
gf_path={$SERVER_PATH}/go-fastdfs |
|
||||||
|
|
||||||
gf_start(){ |
|
||||||
isStart=`ps -ef| grep -v python|grep -v bash |grep go-fastdfs |grep -v .jar | grep -v grep|awk '{print $2}'` |
|
||||||
if [ "$isStart" == '' ];then |
|
||||||
echo -e "Starting go-fastdfs... \c" |
|
||||||
cd $gf_path |
|
||||||
nohup ./go-fastdfs > /dev/null 2>&1 & |
|
||||||
echo -e "\033[32mdone\033[0m" |
|
||||||
else |
|
||||||
echo -e "Starting go-fastdfs(pid $(echo $isStart)) already running" |
|
||||||
fi |
|
||||||
} |
|
||||||
|
|
||||||
|
|
||||||
gf_stop() |
|
||||||
{ |
|
||||||
echo -e "Stopping go-fastdfs... \c" |
|
||||||
|
|
||||||
pids=$(ps -ef| grep -v python |grep -v bash |grep go-fastdfs |grep -v .jar | grep -v grep | awk '{print $2}') |
|
||||||
arr=($pids) |
|
||||||
|
|
||||||
for p in ${arr[@]} |
|
||||||
do |
|
||||||
kill -9 $p |
|
||||||
done |
|
||||||
echo -e "\033[32mdone\033[0m" |
|
||||||
} |
|
||||||
|
|
||||||
gf_status() |
|
||||||
{ |
|
||||||
isStart=$(ps -ef | grep -v python | grep -v bash | grep go-fastdfs |grep -v .jar | grep -v grep | awk '{print $2}') |
|
||||||
if [ "$isStart" != '' ];then |
|
||||||
echo -e "\033[32mgo-fastdfs (pid $(echo $isStart)) already running\033[0m" |
|
||||||
else |
|
||||||
echo -e "\033[31mgo-fastdfs not running\033[0m" |
|
||||||
fi |
|
||||||
} |
|
||||||
|
|
||||||
|
|
||||||
gf_reload() |
|
||||||
{ |
|
||||||
gf_stop |
|
||||||
gf_start |
|
||||||
} |
|
||||||
|
|
||||||
case "$1" in |
|
||||||
'start') gf_start;; |
|
||||||
'stop') gf_stop;; |
|
||||||
'reload') gf_reload;; |
|
||||||
'status') gf_status;; |
|
||||||
'restart') |
|
||||||
gf_stop |
|
||||||
gf_start;; |
|
||||||
esac |
|
@ -1,75 +0,0 @@ |
|||||||
#!/bin/bash |
|
||||||
PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:~/bin |
|
||||||
export PATH |
|
||||||
|
|
||||||
curPath=`pwd` |
|
||||||
rootPath=$(dirname "$curPath") |
|
||||||
rootPath=$(dirname "$rootPath") |
|
||||||
serverPath=$(dirname "$rootPath") |
|
||||||
sysName=`uname` |
|
||||||
|
|
||||||
install_tmp=${rootPath}/tmp/mw_install.pl |
|
||||||
|
|
||||||
action=$1 |
|
||||||
version=$2 |
|
||||||
Install_gf() |
|
||||||
{ |
|
||||||
echo '正在安装脚本文件...' > $install_tmp |
|
||||||
mkdir -p $serverPath/go-fastdfs |
|
||||||
FF_DIR=${serverPath}/go-fastdfs |
|
||||||
cd $FF_DIR |
|
||||||
|
|
||||||
if [ $sysName == 'Darwin' ]; then |
|
||||||
FF_SS_DIR=${serverPath}/source/go-fastdfs |
|
||||||
mkdir -p $FF_SS_DIR |
|
||||||
if [ ! -f $FF_SS_DIR/v1.3.1.tar.gz ]; then |
|
||||||
wget -O $FF_SS_DIR/v1.3.1.tar.gz https://github.com/sjqzhang/go-fastdfs/archive/v1.3.1.tar.gz |
|
||||||
fi |
|
||||||
|
|
||||||
if [ ! -d $FF_SS_DIR/go-fastdfs-1.3.1 ]; then |
|
||||||
cd $FF_SS_DIR && tar -zxvf $FF_SS_DIR/v1.3.1.tar.gz |
|
||||||
fi |
|
||||||
|
|
||||||
|
|
||||||
cd $FF_SS_DIR/go-fastdfs-1.3.1 |
|
||||||
|
|
||||||
if [ -d $FF_SS_DIR/go-fastdfs-1.3.1/vendor ];then |
|
||||||
mv vendor src |
|
||||||
fi |
|
||||||
|
|
||||||
if [ ! -f $FF_SS_DIR/go-fastdfs-1.3.1/fileserver ]; then |
|
||||||
pwd=`pwd` |
|
||||||
echo "$pwd go build -o fileserver fileserver.go" |
|
||||||
GOPATH=$pwd go build -o fileserver fileserver.go |
|
||||||
fi |
|
||||||
|
|
||||||
if [ ! -f $FF_DIR/go-fastdfs ];then |
|
||||||
cp -f fileserver $FF_DIR/go-fastdfs |
|
||||||
|
|
||||||
cd $FF_DIR |
|
||||||
fi |
|
||||||
else |
|
||||||
cd $FF_DIR |
|
||||||
if [ ! -f ${FF_DIR}/fileserver ];then |
|
||||||
wget --no-check-certificate https://github.com/sjqzhang/go-fastdfs/releases/download/v1.3.1/fileserver -O fileserver |
|
||||||
chmod +x fileserver |
|
||||||
fi |
|
||||||
fi |
|
||||||
|
|
||||||
|
|
||||||
echo "$version" > $FF_DIR/version.pl |
|
||||||
echo '安装完成' > $install_tmp |
|
||||||
} |
|
||||||
|
|
||||||
Uninstall_gf() |
|
||||||
{ |
|
||||||
rm -rf $serverPath/go-fastdfs |
|
||||||
echo "卸载完成" > $install_tmp |
|
||||||
} |
|
||||||
|
|
||||||
|
|
||||||
if [ "${1}" == 'install' ];then |
|
||||||
Install_gf $version |
|
||||||
else |
|
||||||
Uninstall_gf $version |
|
||||||
fi |
|
@ -1,93 +0,0 @@ |
|||||||
function str2Obj(str){ |
|
||||||
var data = {}; |
|
||||||
kv = str.split('&'); |
|
||||||
for(i in kv){ |
|
||||||
v = kv[i].split('='); |
|
||||||
data[v[0]] = v[1]; |
|
||||||
} |
|
||||||
return data; |
|
||||||
} |
|
||||||
|
|
||||||
function pPost(method,args,callback, title){ |
|
||||||
|
|
||||||
var _args = null;
|
|
||||||
if (typeof(args) == 'string'){ |
|
||||||
_args = JSON.stringify(str2Obj(args)); |
|
||||||
} else { |
|
||||||
_args = JSON.stringify(args); |
|
||||||
} |
|
||||||
|
|
||||||
var _title = '正在获取...'; |
|
||||||
if (typeof(title) != 'undefined'){ |
|
||||||
_title = title; |
|
||||||
} |
|
||||||
|
|
||||||
var loadT = layer.msg(_title, { icon: 16, time: 0, shade: 0.3 }); |
|
||||||
$.post('/plugins/run', {name:'go-fastdfs', func:method, args:_args}, function(data) { |
|
||||||
layer.close(loadT); |
|
||||||
if (!data.status){ |
|
||||||
layer.msg(data.msg,{icon:0,time:2000,shade: [0.3, '#000']}); |
|
||||||
return; |
|
||||||
} |
|
||||||
|
|
||||||
if(typeof(callback) == 'function'){ |
|
||||||
callback(data); |
|
||||||
} |
|
||||||
},'json');
|
|
||||||
} |
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
function gfConfigSet(){ |
|
||||||
pPost('gf_conf_set', '', function(data){ |
|
||||||
var rdata = $.parseJSON(data.data); |
|
||||||
|
|
||||||
var mlist = ''; |
|
||||||
for (var i = 0; i < rdata.length; i++) { |
|
||||||
var w = '140'; |
|
||||||
if (rdata[i].name == 'error_reporting') w = '250'; |
|
||||||
var ibody = '<input style="width: ' + w + 'px;" class="bt-input-text mr5" name="' + rdata[i].name + '" value="' + rdata[i].value + '" type="text" >'; |
|
||||||
switch (rdata[i].type) { |
|
||||||
case 0: |
|
||||||
var selected_1 = (rdata[i].value == 1) ? 'selected' : ''; |
|
||||||
var selected_0 = (rdata[i].value == 0) ? 'selected' : ''; |
|
||||||
ibody = '<select class="bt-input-text mr5" name="' + rdata[i].name + '" style="width: ' + w + 'px;">\ |
|
||||||
<option value="1" ' + selected_1 + '>开启</option>\ |
|
||||||
<option value="0" ' + selected_0 + '>关闭</option>\ |
|
||||||
</select>'; |
|
||||||
break; |
|
||||||
case 1: |
|
||||||
var selected_1 = (rdata[i].value == 'On') ? 'selected' : ''; |
|
||||||
var selected_0 = (rdata[i].value == 'Off') ? 'selected' : ''; |
|
||||||
ibody = '<select class="bt-input-text mr5" name="' + rdata[i].name + '" style="width: ' + w + 'px;">\ |
|
||||||
<option value="On" ' + selected_1 + '>开启</option>\ |
|
||||||
<option value="Off" ' + selected_0 + '>关闭</option></select>' |
|
||||||
break; |
|
||||||
case 2: |
|
||||||
var selected_1 = (rdata[i].value == 'true') ? 'selected' : ''; |
|
||||||
var selected_0 = (rdata[i].value == 'false') ? 'selected' : ''; |
|
||||||
ibody = '<select class="bt-input-text mr5" name="' + rdata[i].name + '" style="width: ' + w + 'px;">\ |
|
||||||
<option value="true" ' + selected_1 + '>开启</option>\ |
|
||||||
<option value="false" ' + selected_0 + '>关闭</option></select>' |
|
||||||
break; |
|
||||||
} |
|
||||||
mlist += '<p><span>' + rdata[i].name + '</span>' + ibody + ', <font>' + rdata[i].ps + '</font></p>' |
|
||||||
} |
|
||||||
var html = '<style>.conf_p p{margin-bottom: 2px}</style><div class="conf_p" style="margin-bottom:0">\ |
|
||||||
' + mlist + '\ |
|
||||||
<div style="margin-top:10px; padding-right:15px" class="text-right">\ |
|
||||||
</div>'; |
|
||||||
$(".soft-man-con").html(html); |
|
||||||
}); |
|
||||||
} |
|
||||||
|
|
||||||
|
|
||||||
function pRead(){ |
|
||||||
var readme = '<ul class="help-info-text c7">'; |
|
||||||
readme += '<li>官方地址<a target="_blank" href="https://github.com/sjqzhang/go-fastdfs">查看</a></li>'; |
|
||||||
readme += '<li>如果开启防火墙,需要放行端口,例如(8080)</li>'; |
|
||||||
readme += '<li>要自行配置openresty</li>'; |
|
||||||
readme += '</ul>'; |
|
||||||
|
|
||||||
$('.soft-man-con').html(readme);
|
|
||||||
} |
|
Loading…
Reference in new issue