diff --git a/plugins/go-fastdfs/index.html b/plugins/go-fastdfs/index.html
index af94b56ba..2377b94c4 100755
--- a/plugins/go-fastdfs/index.html
+++ b/plugins/go-fastdfs/index.html
@@ -16,6 +16,6 @@
\ No newline at end of file
diff --git a/plugins/go-fastdfs/index.py b/plugins/go-fastdfs/index.py
index 922880dfd..fd699447e 100755
--- a/plugins/go-fastdfs/index.py
+++ b/plugins/go-fastdfs/index.py
@@ -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:(.*)\}"
- 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'
diff --git a/plugins/go-fastdfs/init.d/go-fastdfs.tpl b/plugins/go-fastdfs/init.d/go-fastdfs.tpl
new file mode 100644
index 000000000..f4798d18a
--- /dev/null
+++ b/plugins/go-fastdfs/init.d/go-fastdfs.tpl
@@ -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
\ No newline at end of file
diff --git a/plugins/go-fastdfs/init.d/gofastdfs.tpl b/plugins/go-fastdfs/init.d/gofastdfs.tpl
deleted file mode 100644
index c2194130a..000000000
--- a/plugins/go-fastdfs/init.d/gofastdfs.tpl
+++ /dev/null
@@ -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
diff --git a/plugins/go-fastdfs/install.sh b/plugins/go-fastdfs/install.sh
index 9d0a5aaba..883348ece 100755
--- a/plugins/go-fastdfs/install.sh
+++ b/plugins/go-fastdfs/install.sh
@@ -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
}
diff --git a/plugins/go-fastdfs/js/fastdfs.js b/plugins/go-fastdfs/js/fastdfs.js
index be5e7d1f4..1243aad12 100755
--- a/plugins/go-fastdfs/js/fastdfs.js
+++ b/plugins/go-fastdfs/js/fastdfs.js
@@ -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 += '
';
- con += '';
- con += '| collection | ';
- con += '操作(添加)'+ '|'+ 'WEB管理 | ';
- con += '
';
-
- con += '';
-
- for (var i = 0; i < list.length; i++) {
- con += ''+
- '| ' + list[i]['name']+' | ' +
- '\
- 命令 \
- | 配置 \
- | 删除 | \
-
';
- }
-
- con += '';
- con += '
';
-
- $(".soft-man-con").html(con);
- });
-}
-
-
-function addCollection(){
- var loadOpen = layer.open({
- type: 1,
- title: '添加Collection',
- area: '400px',
- content:"",
- });
-
- $('#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:""
- });
-
- $('#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 += '';
- html += '';
-
- var loadOpen = layer.open({
- type: 1,
- title: '['+name+']配置设置',
- area: '240px',
- content:''+html+'
'
- });
-}
-
-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 = '';
- cmd += '| 增量更新 | curl "http://127.0.0.1:8983/solr/'+name+'/dataimport?command=delta-import&wt=json&clean=false&commit=true" |
';
- cmd += '| 权限更新 | curl "http://127.0.0.1:8983/solr/'+name+'/dataimport?command=full-import&wt=json&clean=false&commit=true" | |
';
- cmd += '| 默认端口:8983(可修改),默认IP为本地,可修改。 |
';
- cmd += '
';
-
- layer.open({
- type: 1,
- title: '命令',
- area: '750px',
- content:cmd,
- });
-}
-
function pRead(){
var readme = '';
readme += '- 使用默认solr端口,如有需要自行修改
';