|
@@ -6,6 +6,7 @@ import daemon
|
|
|
import logging
|
|
|
import sys
|
|
|
import time
|
|
|
+import threading
|
|
|
|
|
|
from ffstatus import *
|
|
|
|
|
@@ -22,6 +23,8 @@ parser.add_argument('-G', '--graphite-host', help='Graphite host')
|
|
|
parser.add_argument('--graphite-port', type=int, default=2003, help='Graphite port')
|
|
|
parser.add_argument('--dashing-url', help='Dashing URL')
|
|
|
parser.add_argument('--dashing-token', help='Dashing\'s secret update token')
|
|
|
+parser.add_argument('--api-bind-host', default='::', help='API-Server Hostname')
|
|
|
+parser.add_argument('--api-bind-port', type=int, default=8888, help='API-Server Port')
|
|
|
args = parser.parse_args()
|
|
|
|
|
|
if args.interval < 5:
|
|
@@ -71,6 +74,12 @@ for i in [ ('AlfredParser', a), ('BatmanParser', b) ]:
|
|
|
print('FAILED SANITY CHECK: ' + str(err))
|
|
|
sys.exit(1)
|
|
|
|
|
|
+server = ApiServer((args.api_bind_host, args.api_bind_port), storage)
|
|
|
+server_thread = threading.Thread(target=server.serve_forever)
|
|
|
+server_thread.daemon = True # exit thread when main thread terminates
|
|
|
+server_thread.start()
|
|
|
+logger.info('Started server: ' + str(server))
|
|
|
+
|
|
|
if shall_daemonize:
|
|
|
daemon_context = daemon.DaemonContext(
|
|
|
files_preserve = [ fh.stream ],
|