This commit is contained in:
midoks 2022-06-20 16:14:22 +08:00
parent 0c66018e63
commit d5483f69df
7 changed files with 0 additions and 513 deletions

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.3 KiB

View File

@ -1,22 +0,0 @@
<div class="bt-form">
<div class="bt-w-main">
<div class="bt-w-menu">
<p class="bgw" onclick="pluginService('walle');">服务</p>
<p onclick="pluginInitD('walle');">自启动</p>
<p onclick="pluginConfig('walle','', 'prod_conf');">配置[Python]</p>
<p onclick="pluginCmd();">命令</p>
<p onclick="pluginLogs('walle','','run_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=walle&f=js/walle.js", function() {
pluginService('walle');
});
</script>

View File

@ -1,211 +0,0 @@
# coding: utf-8
import time
import random
import os
import json
import re
import sys
import subprocess
sys.path.append(os.getcwd() + "/class/core")
import mw
app_debug = False
if mw.isAppleSystem():
app_debug = True
def getPluginName():
return 'walle'
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() + "/code/logs/error.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()
cmd = "ps -ef|grep 'waller.py' | grep -v grep | awk '{print $2}'"
data = mw.execShell(cmd)
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 runShell(shell):
data = mw.execShell(shell)
return data
def start():
file = initDreplace()
cmd = file + ' start'
data = subprocess.Popen(
cmd, shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
return 'ok'
def stop():
file = initDreplace()
data = runShell(file + ' stop')
if data[1] == '':
return 'ok'
return 'fail'
def restart():
file = initDreplace()
cmd = file + ' restart'
data = subprocess.Popen(
cmd, shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
return 'ok'
def reload():
file = initDreplace()
data = runShell(file + ' reload')
solr_log = getServerDir() + "/code/logs/walle.log"
mw.writeFile(solr_log, "")
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 prodConf():
return getServerDir() + "/code/walle/config/settings_prod.py"
def initEnv():
cmd = "cd " + getServerDir() + "/code" + " && sh admin.sh init"
data = mw.execShell(cmd)
return "shell:<br>" + data[0] + "<br>" + " error:<br>" + data[1]
def initData():
cmd = "cd " + getServerDir() + "/code" + " && sh admin.sh migration"
data = mw.execShell(cmd)
return "shell:<br>" + data[0] + "<br>" + " error:<br>" + data[1]
# rsyncdReceive
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 == 'prod_conf':
print(prodConf())
elif func == 'init_env':
print(initEnv())
elif func == 'init_data':
print(initData())
else:
print('error')

View File

@ -1,16 +0,0 @@
{
"id":12,
"title":"walle",
"tip":"soft",
"name":"walle",
"type":"扩展",
"ps":"一款开源的代码部署管理工具",
"versions":"1.0",
"shell":"install.sh",
"checks":"server/walle",
"path": "server/walle",
"author":"midoks",
"home":"",
"date":"2019-12-05",
"pid":"3"
}

View File

@ -1,114 +0,0 @@
#!/bin/bash
# chkconfig: 2345 55 25
# description: Walle 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 walle
# Description: starts the walle
### END INIT INFO
PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:~/bin
app_path={$SERVER_PATH}/walle/code
walle_start(){
isStart=`ps aux | grep 'waller.py'| grep -v grep | awk '{print $2}'`
if [ "$isStart" == '' ];then
echo -e "Starting walle... \c"
cd $app_path && python waller.py >> $app_path/logs/walle.log 2>&1 &
sleep 0.3
isStart=`ps aux | grep 'waller.py' | grep -v grep | awk '{print $2}'`
sleep 0.2
if [ "$isStart" == '' ];then
echo -e "\033[31mfailed\033[0m"
echo '------------------------------------------------------'
tail -n 20 $app_path/logs/walle.log
echo '------------------------------------------------------'
echo -e "\033[31mError: walle service startup failed.\033[0m"
return
fi
echo -e "\033[32mdone\033[0m"
else
echo "Starting ... walle (pid $isStart) already running"
fi
}
walle_stop()
{
echo -e "Stopping walle... \c";
pids=$(ps aux | grep 'waller.py'|grep -v grep|awk '{print $2}')
arr=($pids)
for p in ${arr[@]}
do
kill -9 $p
done
echo -e "\033[32mdone\033[0m"
echo -e "Stopping walle... \c";
arr=`ps aux | grep 'waller.py' | grep -v grep | awk '{print $2}'`
for p in ${arr[@]}
do
kill -9 $p &>/dev/null
done
if [ -f $pidfile ];then
rm -f $pidfile
fi
echo -e "\033[32mdone\033[0m"
}
walle_reload()
{
isStart=$(ps aux | grep 'waller.py' | grep -v grep | awk '{print $2}')
if [ "$isStart" != '' ];then
echo -e "Reload walle... \c";
arr=`ps aux|grep 'waller.py' |grep -v grep|awk '{print $2}'`
for p in ${arr[@]}
do
kill -9 $p
done
cd $app_path && nohup python waller.py >> $app_path/logs/walle.log 2>&1 &
isStart=`ps aux | grep 'waller.py' | grep -v grep | awk '{print $2}'`
if [ "$isStart" == '' ];then
echo -e "\033[31mfailed\033[0m"
echo '------------------------------------------------------'
tail -n 20 $app_path/logs/walle.log
echo '------------------------------------------------------'
echo -e "\033[31mError: walle service startup failed.\033[0m"
return
fi
echo -e "\033[32mdone\033[0m"
else
echo -e "\033[31m walle not running\033[0m"
mw_start
fi
}
error_logs()
{
tail -n 100 ${app_path}/logs/walle.log
}
case "$1" in
'start') walle_start;;
'stop') walle_stop;;
'reload') walle_reload;;
'restart')
walle_stop
walle_start;;
'logs') error_logs;;
esac

View File

@ -1,51 +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")
install_tmp=${rootPath}/tmp/mw_install.pl
Install_walle()
{
echo '正在安装脚本文件...' > $install_tmp
mkdir -p $serverPath/walle
echo '1.0' > $serverPath/walle/version.pl
if [ ! -f $serverPath/source/v2.0.1.tar.gz ];then
wget -O $serverPath/source/v2.0.1.tar.gz https://github.com/meolu/walle-web/archive/v2.0.1.tar.gz
fi
if [ ! -d $serverPath/source/walle-web-2.0.1 ];then
cd $serverPath/source && tar -zxvf v2.0.1.tar.gz
fi
if [ ! -d $serverPath/walle/code ];then
mkdir -p $serverPath/walle/code
cp -rf $serverPath/source/walle-web-2.0.1/* $serverPath/walle/code/
fi
cd $serverPath/walle/code && pip install -r $serverPath/walle/code/requirements/prod.txt
echo '安装完成' > $install_tmp
}
Uninstall_walle()
{
rm -rf $serverPath/walle
echo "卸载完成" > $install_tmp
}
action=$1
if [ "${1}" == 'install' ];then
Install_walle
else
Uninstall_walle
fi

View File

@ -1,99 +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:'walle', 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 pPostCallbak(method, version, args,callback){
var loadT = layer.msg('正在获取...', { icon: 16, time: 0, shade: 0.3 });
var req_data = {};
req_data['name'] = 'walle';
req_data['func'] = method;
args['version'] = version;
if (typeof(args) == 'string'){
req_data['args'] = JSON.stringify(str2Obj(args));
} else {
req_data['args'] = JSON.stringify(args);
}
$.post('/plugins/callback', req_data, 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 initEnv(){
pPost('init_env', {}, function(data){
layer.msg(data.data,{icon:1,time:6000,shade: [0.3, '#000']});
},'初始化环境');
}
function initData(){
pPost('init_data', {}, function(data){
layer.msg(data.data,{icon:1,time:6000,shade: [0.3, '#000']});
},'初始化数据');
}
function pluginCmd(){
var serviceCon ='<p class="status">当前可以运行的命令<span></span><span style="color: #20a53a;margin-left: 3px;" class="glyphicon"></span></p>\
<div class="sfm-opt">\
<button class="btn btn-default btn-sm" onclick="initEnv()">初始化环境</button>\
<button class="btn btn-default btn-sm" onclick="initData()">初始化数据</button>\
</div>';
$(".soft-man-con").html(serviceCon);
}
function pRead(){
var readme = '<ul class="help-info-text c7">';
readme += '<li>使用默认walle端口5000,如有需要自行修改</li>';
readme += '<li>修改配置正确后:</li>';
readme += '<li>手动[初始化环境]:sh admin.sh init</li>';
readme += '<li>手动[初始化数据]:sh admin.sh migration</li>';
readme += '<li><a target="_blank" href="https://walle-web.io/docs/installation_docker.html">官方文档</a></li>';
readme += '</ul>';
$('.soft-man-con').html(readme);
}