Resolve a gihub python-processor issue 2
This commit is contained in:
@@ -0,0 +1,25 @@
|
||||
import threading
|
||||
from BaseHTTPServer import HTTPServer, BaseHTTPRequestHandler
|
||||
|
||||
class HttpHealthServer(BaseHTTPRequestHandler):
|
||||
def do_GET(self):
|
||||
if (self.path == '/actuator/health') or (self.path == '/actuator/info'):
|
||||
self.send_ok_response()
|
||||
else:
|
||||
self.send_missing_response()
|
||||
|
||||
self.send_header('Content-type', 'text/html')
|
||||
self.end_headers()
|
||||
|
||||
def send_ok_response(self):
|
||||
self.send_response(200)
|
||||
|
||||
def send_missing_response(self):
|
||||
self.send_response(404)
|
||||
|
||||
@staticmethod
|
||||
def run_thread(port=8080):
|
||||
http_server = HTTPServer(('', port), HttpHealthServer)
|
||||
thread = threading.Thread(name='httpd_server', target=http_server.serve_forever)
|
||||
thread.setDaemon(True)
|
||||
thread.start()
|
||||
@@ -0,0 +1,33 @@
|
||||
import os
|
||||
import sys
|
||||
from collections import defaultdict
|
||||
|
||||
def get_cmd_arg(name):
|
||||
d = defaultdict(list)
|
||||
for cmd_args in sys.argv[1:]:
|
||||
cmd_arg = cmd_args.split('=')
|
||||
if len(cmd_arg) == 2:
|
||||
d[cmd_arg[0].lstrip('-')].append(cmd_arg[1])
|
||||
|
||||
if name in d:
|
||||
return d[name][0]
|
||||
else:
|
||||
print('Unknown command line arg requested: {}'.format(name))
|
||||
|
||||
def get_env_var(name):
|
||||
if name in os.environ:
|
||||
return os.environ[name]
|
||||
else:
|
||||
print('Unknown environment variable requested: {}'.format(name))
|
||||
|
||||
def get_kafka_binder_brokers():
|
||||
return get_env_var('SPRING_CLOUD_STREAM_KAFKA_BINDER_BROKERS')
|
||||
|
||||
def get_input_channel():
|
||||
return get_cmd_arg("spring.cloud.stream.bindings.input.destination")
|
||||
|
||||
def get_output_channel():
|
||||
return get_cmd_arg("spring.cloud.stream.bindings.output.destination")
|
||||
|
||||
def get_reverse_string():
|
||||
return get_cmd_arg("reverestring")
|
||||
Reference in New Issue
Block a user