mirror of
https://github.com/midoks/mdserver-web.git
synced 2026-10-18 23:45:52 +08:00
up
This commit is contained in:
@@ -16,6 +16,6 @@
|
||||
<script type="text/javascript">
|
||||
resetPluginWinWidth(700);
|
||||
$.getScript( "/plugins/file?name=go-fastdfs&f=js/fastdfs.js", function() {
|
||||
pluginService('solr');
|
||||
pluginService('go-fastdfs');
|
||||
});
|
||||
</script>
|
||||
@@ -6,6 +6,7 @@ import os
|
||||
import json
|
||||
import re
|
||||
import sys
|
||||
import subprocess
|
||||
|
||||
sys.path.append(os.getcwd() + "/class/core")
|
||||
import public
|
||||
@@ -83,16 +84,10 @@ def initDreplace():
|
||||
if not os.path.exists(initD_path):
|
||||
os.mkdir(initD_path)
|
||||
|
||||
user = 'www'
|
||||
if public.getOs() == 'darwin':
|
||||
user = public.execShell(
|
||||
"who | sed -n '2, 1p' |awk '{print $1}'")[0].strip()
|
||||
|
||||
file_bin = initD_path + '/' + getPluginName()
|
||||
if not os.path.exists(file_bin):
|
||||
content = public.readFile(file_tpl)
|
||||
content = content.replace('{$SERVER_PATH}', service_path)
|
||||
content = content.replace('{$RUN_USER}', user)
|
||||
public.writeFile(file_bin, content)
|
||||
public.execShell('chmod +x ' + file_bin)
|
||||
|
||||
@@ -101,10 +96,9 @@ def initDreplace():
|
||||
|
||||
def start():
|
||||
file = initDreplace()
|
||||
data = public.execShell(file + ' start')
|
||||
if data[1] == '':
|
||||
return 'ok'
|
||||
return 'fail'
|
||||
# data = public.execShell(file + ' start')
|
||||
subprocess.Popen(file + ' start', shell=True)
|
||||
return 'ok'
|
||||
|
||||
|
||||
def stop():
|
||||
@@ -161,78 +155,6 @@ def initdUinstall():
|
||||
os.remove(initd_bin)
|
||||
return 'ok'
|
||||
|
||||
|
||||
def collectionList():
|
||||
path = getServerDir() + '/server/solr'
|
||||
listDir = os.listdir(path)
|
||||
data = {}
|
||||
dlist = []
|
||||
for dirname in listDir:
|
||||
dirpath = path + '/' + dirname
|
||||
if not os.path.isdir(dirpath):
|
||||
continue
|
||||
if dirname == 'configsets':
|
||||
continue
|
||||
|
||||
tmp = {}
|
||||
tmp['name'] = dirname
|
||||
dlist.append(tmp)
|
||||
data['list'] = dlist
|
||||
data['ip'] = public.getLocalIp()
|
||||
data['port'] = '8983'
|
||||
|
||||
content = public.readFile(path+'/solr.xml')
|
||||
|
||||
rep = "jetty.port:(.*)\}</int>"
|
||||
tmp = re.search(rep, content)
|
||||
port = tmp.groups()[0]
|
||||
data['port'] = port
|
||||
|
||||
return public.returnJson(True, 'OK', data)
|
||||
|
||||
|
||||
def addCollection():
|
||||
args = getArgs()
|
||||
data = checkArgs(args, ['name'])
|
||||
if not data[0]:
|
||||
return data[1]
|
||||
|
||||
name = args['name']
|
||||
solr_bin = getServerDir() + "/bin/solr"
|
||||
|
||||
retdata = public.execShell(solr_bin + ' create -c ' + name)
|
||||
if retdata[1] != "":
|
||||
return public.returnJson(False, '添加失败!:' + retdata[0])
|
||||
return public.returnJson(True, '添加成功!:' + retdata[0])
|
||||
|
||||
|
||||
def removeCollection():
|
||||
args = getArgs()
|
||||
data = checkArgs(args, ['name'])
|
||||
if not data[0]:
|
||||
return data[1]
|
||||
|
||||
name = args['name']
|
||||
solr_bin = getServerDir() + "/bin/solr"
|
||||
|
||||
retdata = public.execShell(solr_bin + ' delete -c ' + name)
|
||||
if retdata[1] != "":
|
||||
return public.returnJson(False, '添加失败!:' + retdata[0])
|
||||
return public.returnJson(True, '添加成功!:' + retdata[0])
|
||||
|
||||
|
||||
def confFileCollection():
|
||||
args = getArgs()
|
||||
data = checkArgs(args, ['name'])
|
||||
if not data[0]:
|
||||
return data[1]
|
||||
|
||||
conf_file = getServerDir() + "/server/solr/" + \
|
||||
args['name'] + "/conf/" + args['conf_file']
|
||||
# print conf_file
|
||||
return public.returnJson(True, 'OK', {'path': conf_file})
|
||||
|
||||
|
||||
# rsyncdReceive
|
||||
if __name__ == "__main__":
|
||||
func = sys.argv[1]
|
||||
@@ -254,13 +176,5 @@ if __name__ == "__main__":
|
||||
print initdUinstall()
|
||||
elif func == 'run_log':
|
||||
print getLog()
|
||||
elif func == 'collection_list':
|
||||
print collectionList()
|
||||
elif func == 'add_collection':
|
||||
print addCollection()
|
||||
elif func == 'remove_collection':
|
||||
print removeCollection()
|
||||
elif func == 'conf_file_collection':
|
||||
print confFileCollection()
|
||||
else:
|
||||
print 'error'
|
||||
|
||||
@@ -0,0 +1,70 @@
|
||||
#!/bin/bash
|
||||
# chkconfig: 2345 55 25
|
||||
# description: MW 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 mw
|
||||
# Description: starts the mw
|
||||
### 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 'go-fastdfs' | grep -v grep|awk '{print $2}'`
|
||||
if [ "$isStart" == '' ];then
|
||||
echo -e "Starting go-fastdfs... \c"
|
||||
cd $gf_path && chmod +x go-fastdfs && ./go-fastdfs 1> /dev/null 2>/dev/null &
|
||||
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 aux|grep 'go-fastdfs'| 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 aux | grep 'go-fastdfs' | 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,78 +0,0 @@
|
||||
#!/bin/sh
|
||||
# Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
# contributor license agreements. See the NOTICE file distributed with
|
||||
# this work for additional information regarding copyright ownership.
|
||||
# The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
# (the "License"); you may not use this file except in compliance with
|
||||
# the License. You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
### BEGIN INIT INFO
|
||||
# Provides: solr
|
||||
# Required-Start: $remote_fs $syslog
|
||||
# Required-Stop: $remote_fs $syslog
|
||||
# Default-Start: 2 3 4 5
|
||||
# Default-Stop: 0 1 6
|
||||
# Description: Controls Apache Solr as a Service
|
||||
### END INIT INFO
|
||||
|
||||
# Example of a very simple *nix init script that delegates commands to the bin/solr script
|
||||
# Typical usage is to do:
|
||||
#
|
||||
# cp bin/init.d/solr /etc/init.d/solr
|
||||
# chmod 755 /etc/init.d/solr
|
||||
# chown root:root /etc/init.d/solr
|
||||
# update-rc.d solr defaults
|
||||
# update-rc.d solr enable
|
||||
|
||||
# Where you extracted the Solr distribution bundle
|
||||
SOLR_INSTALL_DIR="{$SERVER_PATH}/solr"
|
||||
|
||||
if [ ! -d "$SOLR_INSTALL_DIR" ]; then
|
||||
echo "$SOLR_INSTALL_DIR not found! Please check the SOLR_INSTALL_DIR setting in your $0 script."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Path to an include file that defines environment specific settings to override default
|
||||
# variables used by the bin/solr script. It's highly recommended to define this script so
|
||||
# that you can keep the Solr binary files separated from live files (pid, logs, index data, etc)
|
||||
# see bin/solr.in.sh for an example
|
||||
SOLR_ENV="{$SERVER_PATH}/solr/bin/solr.in.sh"
|
||||
|
||||
if [ ! -f "$SOLR_ENV" ]; then
|
||||
echo "$SOLR_ENV not found! Please check the SOLR_ENV setting in your $0 script."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Specify the user to run Solr as; if not set, then Solr will run as root.
|
||||
# Running Solr as root is not recommended for production environments
|
||||
RUNAS="{$RUN_USER}"
|
||||
|
||||
# verify the specified run as user exists
|
||||
runas_uid="`id -u "$RUNAS"`"
|
||||
if [ $? -ne 0 ]; then
|
||||
echo "User $RUNAS not found! Please create the $RUNAS user before running this script."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
case "$1" in
|
||||
start|stop|restart|status)
|
||||
SOLR_CMD="$1"
|
||||
;;
|
||||
*)
|
||||
echo "Usage: $0 {start|stop|restart|status}"
|
||||
exit
|
||||
esac
|
||||
|
||||
if [ -n "$RUNAS" ]; then
|
||||
sh -c "SOLR_INCLUDE=\"$SOLR_ENV\" \"$SOLR_INSTALL_DIR/bin/solr\" $SOLR_CMD" - "$RUNAS"
|
||||
else
|
||||
SOLR_INCLUDE="$SOLR_ENV" "$SOLR_INSTALL_DIR/bin/solr" "$SOLR_CMD"
|
||||
fi
|
||||
@@ -43,14 +43,11 @@ Install_gf()
|
||||
GOPATH=$pwd go build -o fileserver fileserver.go
|
||||
fi
|
||||
|
||||
if [ ! -f $FF_DIR/fileserver ];then
|
||||
cp -f fileserver $FF_DIR
|
||||
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
|
||||
@@ -60,7 +57,7 @@ Install_gf()
|
||||
fi
|
||||
|
||||
|
||||
echo "$version" > $serverPath/go-fastdfs/version.pl
|
||||
echo "$version" > $FF_DIR/version.pl
|
||||
echo '安装完成' > $install_tmp
|
||||
}
|
||||
|
||||
|
||||
@@ -37,149 +37,6 @@ function pPost(method,args,callback, title){
|
||||
}
|
||||
|
||||
|
||||
function collectionManagement(){
|
||||
pPost('collection_list', '', function(data){
|
||||
var rdata = $.parseJSON(data.data);
|
||||
if (!rdata.status){
|
||||
layer.msg(rdata.msg,{icon:rdata.status?1:2,time:2000,shade: [0.3, '#000']});
|
||||
return;
|
||||
}
|
||||
|
||||
var list = rdata.data.list;
|
||||
var con = '';
|
||||
con += '<div class="divtable" style="margin-top:5px;"><table class="table table-hover" width="100%" cellspacing="0" cellpadding="0" border="0">';
|
||||
con += '<thead><tr>';
|
||||
con += '<th>collection</th>';
|
||||
con += '<th>操作(<a class="btlink" onclick="addCollection()">添加</a>)'+ '|'+ '<a class="btlink" target="_blank" href="http://'+rdata.data.ip+':'+rdata.data.port+'">WEB管理</a></th>';
|
||||
con += '</tr></thead>';
|
||||
|
||||
con += '<tbody>';
|
||||
|
||||
for (var i = 0; i < list.length; i++) {
|
||||
con += '<tr>'+
|
||||
'<td>' + list[i]['name']+'</td>' +
|
||||
'<td>\
|
||||
<a class="btlink" onclick="cmdCollection(\''+list[i]['name']+'\')">命令</a> \
|
||||
| <a class="btlink" onclick="confCollection(\''+list[i]['name']+'\')">配置</a> \
|
||||
| <a class="btlink" onclick="removeCollection(\''+list[i]['name']+'\')">删除</a></td> \
|
||||
</tr>';
|
||||
}
|
||||
|
||||
con += '</tbody>';
|
||||
con += '</table></div>';
|
||||
|
||||
$(".soft-man-con").html(con);
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
function addCollection(){
|
||||
var loadOpen = layer.open({
|
||||
type: 1,
|
||||
title: '添加Collection',
|
||||
area: '400px',
|
||||
content:"<div class='bt-form pd20 pb70 c6'>\
|
||||
<div class='line'>\
|
||||
<span class='tname'>Collection</span>\
|
||||
<div class='info-r c4'>\
|
||||
<input id='name' class='bt-input-text' type='text' name='name' placeholder='Collection' style='width:200px' />\
|
||||
</div>\
|
||||
</div>\
|
||||
<div class='bt-form-submit-btn'>\
|
||||
<button type='button' id='add_ok' class='btn btn-success btn-sm btn-title bi-btn'>确认</button>\
|
||||
</div>\
|
||||
</div>",
|
||||
});
|
||||
|
||||
$('#add_ok').click(function(){
|
||||
_data = {};
|
||||
_data['name'] = $('#name').val();
|
||||
var loadT = layer.msg('正在获取...', { icon: 16, time: 0, shade: 0.3 });
|
||||
pPost('add_collection', _data, function(data){
|
||||
var rdata = $.parseJSON(data.data);
|
||||
layer.close(loadOpen);
|
||||
layer.msg(rdata.msg,{icon:rdata.status?1:2,time:2000,shade: [0.3, '#000']});
|
||||
setTimeout(function(){collectionManagement();},2000);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
function removeCollection(name){
|
||||
var loadOpen = layer.open({
|
||||
type: 1,
|
||||
title: '删除用户',
|
||||
area: '350px',
|
||||
content:"<div class='bt-form pd20 pb70 c6'>\
|
||||
<div class='version line'>你要确认要删除collection["+ name + "]</div>\
|
||||
<div class='bt-form-submit-btn'>\
|
||||
<button type='button' id='solr_del_close' class='btn btn-danger btn-sm btn-title'>关闭</button>\
|
||||
<button type='button' id='solr_del_ok' class='btn btn-success btn-sm btn-title bi-btn'>确认</button>\
|
||||
</div>\
|
||||
</div>"
|
||||
});
|
||||
|
||||
$('#solr_del_close').click(function(){
|
||||
layer.close(loadOpen);
|
||||
});
|
||||
|
||||
$('#solr_del_ok').click(function(){
|
||||
var _data = {};
|
||||
_data['name'] = name;
|
||||
var loadT = layer.msg('正在获取...', { icon: 16, time: 0, shade: 0.3 });
|
||||
|
||||
_data = {};
|
||||
_data['name'] = name;
|
||||
var loadT = layer.msg('正在获取...', { icon: 16, time: 0, shade: 0.3 });
|
||||
pPost('remove_collection', _data, function(data){
|
||||
var rdata = $.parseJSON(data.data);
|
||||
layer.close(loadOpen);
|
||||
layer.msg(rdata.msg,{icon:rdata.status?1:2,time:2000,shade: [0.3, '#000']});
|
||||
setTimeout(function(){collectionManagement();},2000);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
function confCollection(name){
|
||||
var html = '';
|
||||
html += '<button onclick="confFileCollection(\''+name+'\',\'solrconfig.xml\')" class="btn btn-default btn-sm">solrconfig.xml</button>';
|
||||
html += '<button onclick="confFileCollection(\''+name+'\',\'managed-schema\')" class="btn btn-default btn-sm">managed-schema</button>';
|
||||
|
||||
var loadOpen = layer.open({
|
||||
type: 1,
|
||||
title: '['+name+']配置设置',
|
||||
area: '240px',
|
||||
content:'<div class="change-default pd20">'+html+'</div>'
|
||||
});
|
||||
}
|
||||
|
||||
function confFileCollection(name, conf_file){
|
||||
pPost('conf_file_collection', {'name':name, 'conf_file':conf_file}, function(data){
|
||||
var rdata = $.parseJSON(data.data);
|
||||
if (rdata['status']){
|
||||
onlineEditFile(0, rdata['data']['path']);
|
||||
} else {
|
||||
layer.msg(rdata.msg,{icon:1,time:2000,shade: [0.3, '#000']});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
function cmdCollection(name){
|
||||
var cmd = '<div class="change-default pd20"><table class="table table-hover">';
|
||||
cmd += '<thead><tr><td>增量更新</td><td>curl "http://127.0.0.1:8983/solr/'+name+'/dataimport?command=delta-import&wt=json&clean=false&commit=true"</td></tr>';
|
||||
cmd += '<tr><td>权限更新</td><td>curl "http://127.0.0.1:8983/solr/'+name+'/dataimport?command=full-import&wt=json&clean=false&commit=true"<td></tr>';
|
||||
cmd += '<tr><td colspan="2">默认端口:8983(可修改),默认IP为本地,可修改。</td></tr></thead>';
|
||||
cmd += '</table></div>';
|
||||
|
||||
layer.open({
|
||||
type: 1,
|
||||
title: '命令',
|
||||
area: '750px',
|
||||
content:cmd,
|
||||
});
|
||||
}
|
||||
|
||||
function pRead(){
|
||||
var readme = '<ul class="help-info-text c7">';
|
||||
readme += '<li>使用默认solr端口,如有需要自行修改</li>';
|
||||
|
||||
Reference in New Issue
Block a user