2018-01-15 06:10:16 +00:00
|
|
|
#!/usr/bin/env python3
|
|
|
|
import os, sys
|
2018-01-15 07:56:04 +00:00
|
|
|
import configparser
|
|
|
|
|
2018-01-29 05:13:18 +00:00
|
|
|
path_config = "/opt/haproxy-wi/haproxy-webintarface.config"
|
2018-01-15 07:56:04 +00:00
|
|
|
config = configparser.ConfigParser()
|
|
|
|
config.read(path_config)
|
|
|
|
log_path = config.get('main', 'log_path')
|
|
|
|
fullpath = config.get('main', 'fullpath')
|
|
|
|
server_bind_ip = config.get('main', 'server_bind_ip')
|
|
|
|
server_port = config.getint('main', 'server_port')
|
2018-01-15 06:10:16 +00:00
|
|
|
|
|
|
|
from http.server import HTTPServer, CGIHTTPRequestHandler
|
|
|
|
|
2018-01-26 04:08:34 +00:00
|
|
|
sys.stderr = open(log_path + '/haproxy-monitor.log', 'w')
|
2018-01-15 07:56:04 +00:00
|
|
|
webdir = fullpath
|
2018-01-15 06:10:16 +00:00
|
|
|
os.chdir(webdir)
|
2018-01-15 07:56:04 +00:00
|
|
|
server_address = (server_bind_ip, server_port)
|
2018-01-15 06:10:16 +00:00
|
|
|
httpd = HTTPServer(server_address, CGIHTTPRequestHandler)
|
2018-01-26 04:08:34 +00:00
|
|
|
httpd.serve_forever()
|