mirror of
https://github.com/midoks/mdserver-web.git
synced 2026-10-18 23:45:52 +08:00
update
This commit is contained in:
@@ -2,7 +2,9 @@
|
||||
<div class="bt-w-main">
|
||||
<div class="bt-w-menu">
|
||||
<p class="bgw" onclick="pluginService('simdht');">服务</p>
|
||||
<p onclick="indexPy();">自启动</p>
|
||||
<p onclick="pluginConfig('simdht', '','get_sql');">手动导入SQL</p>
|
||||
<p onclick="pluginConfig('simdht', '','get_db_conf');">配置</p>
|
||||
<p onclick="pluginLogs('simdht','','get_run_Log');">日志</p>
|
||||
</div>
|
||||
<div class="bt-w-con pd15">
|
||||
<div class="soft-man-con">
|
||||
|
||||
+27
-1
@@ -51,6 +51,21 @@ def getInitDTpl():
|
||||
return path
|
||||
|
||||
|
||||
def getSqlFile():
|
||||
file = getPluginDir() + "/conf/simdht.sql"
|
||||
return file
|
||||
|
||||
|
||||
def getDbConf():
|
||||
file = getServerDir() + "/workers/db.cfg"
|
||||
return file
|
||||
|
||||
|
||||
def getRunLog():
|
||||
file = getServerDir() + "/logs.pl"
|
||||
return file
|
||||
|
||||
|
||||
def initDreplace():
|
||||
|
||||
ddir = getServerDir() + '/workers'
|
||||
@@ -76,11 +91,16 @@ def initDreplace():
|
||||
|
||||
|
||||
def status():
|
||||
return 'stop'
|
||||
data = public.execShell(
|
||||
"ps -ef|grep \"python simdht_worker.py\" | grep -v grep | awk '{print $2}'")
|
||||
if data[0] == '':
|
||||
return 'stop'
|
||||
return 'start'
|
||||
|
||||
|
||||
def start():
|
||||
file = initDreplace()
|
||||
|
||||
data = public.execShell(file + ' start')
|
||||
if data[1] == '':
|
||||
return 'ok'
|
||||
@@ -123,5 +143,11 @@ if __name__ == "__main__":
|
||||
print restart()
|
||||
elif func == 'reload':
|
||||
print reload()
|
||||
elif func == 'get_sql':
|
||||
print getSqlFile()
|
||||
elif func == 'get_db_conf':
|
||||
print getDbConf()
|
||||
elif func == 'get_run_Log':
|
||||
print getRunLog()
|
||||
else:
|
||||
print 'error'
|
||||
|
||||
@@ -1,70 +1,40 @@
|
||||
#!/bin/sh
|
||||
# chkconfig: 2345 55 25
|
||||
# description: Redis Service
|
||||
# description: DHTSpider Service
|
||||
|
||||
### BEGIN INIT INFO
|
||||
# Provides: Redis
|
||||
# Provides: DHTSpider
|
||||
# Required-Start: $all
|
||||
# Required-Stop: $all
|
||||
# Default-Start: 2 3 4 5
|
||||
# Default-Stop: 0 1 6
|
||||
# Short-Description: starts Redis
|
||||
# Short-Description: starts DHTSpider
|
||||
# Description: starts the MDW-Web
|
||||
### END INIT INFO
|
||||
|
||||
# Simple Redis init.d script conceived to work on Linux systems
|
||||
# as it does use of the /proc filesystem.
|
||||
|
||||
CONF="{$SERVER_PATH}/redis/redis.conf"
|
||||
REDISPORT=$(cat $CONF |grep port|grep -v '#'|awk '{print $2}')
|
||||
REDISPASS=$(cat $CONF |grep requirepass|grep -v '#'|awk '{print $2}')
|
||||
if [ "$REDISPASS" != "" ];then
|
||||
REDISPASS=" -a $REDISPASS"
|
||||
fi
|
||||
EXEC={$SERVER_PATH}/redis/bin/redis-server
|
||||
CLIEXEC="{$SERVER_PATH}/redis/bin/redis-cli -p $REDISPORT$REDISPASS"
|
||||
PIDFILE={$SERVER_PATH}/redis/redis_6379.pid
|
||||
|
||||
mkdir -p {$SERVER_PATH}/redis/data
|
||||
|
||||
redis_start(){
|
||||
if [ -f $PIDFILE ]
|
||||
then
|
||||
echo "$PIDFILE exists, process is already running or crashed"
|
||||
else
|
||||
echo "Starting Redis server..."
|
||||
nohup $EXEC $CONF >> {$SERVER_PATH}/redis/logs.pl 2>&1 &
|
||||
fi
|
||||
dht_start(){
|
||||
cd {$SERVER_PATH}/simdht/workers
|
||||
nohup python simdht_worker.py >> {$SERVER_PATH}/simdht/logs.pl 2>&1 &
|
||||
}
|
||||
redis_stop(){
|
||||
if [ ! -f $PIDFILE ]
|
||||
then
|
||||
echo "$PIDFILE does not exist, process is not running"
|
||||
else
|
||||
PID=$(cat $PIDFILE)
|
||||
echo "Stopping ..."
|
||||
$CLIEXEC shutdown
|
||||
while [ -x /proc/${PID} ]
|
||||
do
|
||||
echo "Waiting for Redis to shutdown ..."
|
||||
sleep 1
|
||||
done
|
||||
echo "Redis stopped"
|
||||
fi
|
||||
dht_stop(){
|
||||
echo "Stopping ..."
|
||||
ps -ef | grep "python simdht" | grep -v grep | awk '{print $2}' | xargs kill
|
||||
echo "Redis stopped"
|
||||
}
|
||||
|
||||
|
||||
case "$1" in
|
||||
start)
|
||||
redis_start
|
||||
dht_start
|
||||
;;
|
||||
stop)
|
||||
redis_stop
|
||||
dht_stop
|
||||
;;
|
||||
restart|reload)
|
||||
redis_stop
|
||||
dht_stop
|
||||
sleep 0.3
|
||||
redis_start
|
||||
dht_start
|
||||
;;
|
||||
*)
|
||||
echo "Please use start or stop as first argument"
|
||||
|
||||
Reference in New Issue
Block a user