diff --git a/plugins/haproxy/conf/haproxy.conf b/plugins/haproxy/conf/haproxy.conf index 54ca568cf..46243d64e 100755 --- a/plugins/haproxy/conf/haproxy.conf +++ b/plugins/haproxy/conf/haproxy.conf @@ -1,10 +1,38 @@ -global - log 127.0.0.1 local - chroot /var/lib/haproxy - pidfile /var/run/haproxy.pid - maxconn 4000 - user haproxy - group haproxy +global daemon - stats socket /var/lib/haproxy/stats + log 127.0.0.1 local0 + chroot /var/lib/haproxy + pidfile /var/run/haproxy.pid + maxconn 4000 + user haproxy + group haproxy + + +defaults + mode http + log global + option httplog + timeout connect 10s + timeout client 15s + timeout server 15s + + +listen stats + mode http + bind *:10800 + stats enable + stats uri /haproxy + stats realm Haproxy\ Statistics + stats auth admin:admin + +frontend http-in + bind *:1080 + default_backend servers + option forwardfor + option httpclose + +backend servers + balance roundrobin + server web1 0.0.0.0:9090 check + diff --git a/plugins/haproxy/index.py b/plugins/haproxy/index.py index 864fc8763..c4870cba3 100755 --- a/plugins/haproxy/index.py +++ b/plugins/haproxy/index.py @@ -249,37 +249,6 @@ def runStatus(): return mw.returnJson(True, 'ok', rData) -def sphinxConfParse(): - file = getConf() - bin_dir = getServerDir() - content = mw.readFile(file) - rep = 'index\s(.*)' - sindex = re.findall(rep, content) - indexlen = len(sindex) - cmd = {} - if indexlen > 0: - cmd_index = [] - cmd_delta = [] - for x in range(indexlen): - if sindex[x].find(':') != -1: - cmd_delta.append(sindex[x]) - else: - cmd_index.append(sindex[x]) - - cmd['index'] = cmd_index - cmd['delta'] = cmd_delta - cmd['cmd'] = bin_dir + '/bin/bin/indexer -c ' + bin_dir + '/sphinx.conf' - return cmd - - -def sphinxCmd(): - data = sphinxConfParse() - if 'index' in data: - return mw.returnJson(True, 'ok', data) - else: - return mw.returnJson(False, 'no index') - - if __name__ == "__main__": func = sys.argv[1] if func == 'status': @@ -310,7 +279,5 @@ if __name__ == "__main__": print(queryLog()) elif func == 'run_status': print(runStatus()) - elif func == 'sphinx_cmd': - print(sphinxCmd()) else: print('error') diff --git a/plugins/haproxy/init.d/haproxy.service.tpl b/plugins/haproxy/init.d/haproxy.service.tpl index d6e11eac3..aa84b3e4b 100644 --- a/plugins/haproxy/init.d/haproxy.service.tpl +++ b/plugins/haproxy/init.d/haproxy.service.tpl @@ -4,8 +4,9 @@ After=network.target [Service] Type=forking -ExecStart={$SERVER_PATH}/haproxy/sbin/haproxy -c -f {$SERVER_PATH}/haproxy/haproxy.conf -ExecReload=/bin/kill -USR2 $MAINPID +ExecStartPre={$SERVER_PATH}/haproxy/sbin/haproxy -c -f {$SERVER_PATH}/haproxy/haproxy.conf +ExecStart={$SERVER_PATH}/haproxy/sbin/haproxy -Ws -f {$SERVER_PATH}/haproxy/haproxy.conf -p /run/haproxy.pid +ExecReload={$SERVER_PATH}/haproxy/sbin/haproxy -f {$SERVER_PATH}/haproxy/haproxy.conf -c -q Restart=on-failure [Install]