Seperated environment vars from configuration to exclusive object and added a seperate URL (/environment) for requesting data from the HTTP server.
This commit is contained in:
parent
6cb6716862
commit
c319417ee3
7 changed files with 136 additions and 75 deletions
21
bin/uplink
21
bin/uplink
|
|
@ -36,6 +36,7 @@ import sys
|
|||
import time
|
||||
|
||||
from uplink.configuration import Configuration
|
||||
from uplink.environment import Environment
|
||||
from uplink.uplink import Uplink
|
||||
|
||||
"""
|
||||
|
|
@ -48,7 +49,7 @@ MINOR changes are "just-in-time" changes or small enhancements which should not
|
|||
documentation.
|
||||
FIXES should never affect anything else then stability or security.
|
||||
"""
|
||||
__version__ = '0.8.4.2'
|
||||
__version__ = '0.9.0.0'
|
||||
__author__ = 'Johannes Findeisen <you@hanez.org>'
|
||||
|
||||
logger = logging.getLogger('uplink')
|
||||
|
|
@ -108,15 +109,17 @@ def main():
|
|||
logger.error(str('[uplink] configuration error: {0}'.format(err)))
|
||||
sys.exit(1)
|
||||
|
||||
environment = Environment()
|
||||
|
||||
# To be more cross-platform compatible maybe changes are needed:
|
||||
# https://stackoverflow.com/questions/4271740/how-can-i-use-python-to-get-the-system-hostname
|
||||
configuration.set_env_var('_hostname', socket.gethostname())
|
||||
environment.set_env_var('_hostname', socket.gethostname())
|
||||
|
||||
configuration.set_env_var('__version__', __version__)
|
||||
environment.set_env_var('__version__', __version__)
|
||||
|
||||
configuration.set_env_var('_internal_start_date', time.strftime('%Y-%m-%d %H:%M:%S',
|
||||
time.localtime(calendar.timegm(time.gmtime()))))
|
||||
configuration.set_env_var('_internal_start_timestamp', calendar.timegm(time.gmtime()))
|
||||
environment.set_env_var('_internal_start_date', time.strftime('%Y-%m-%d %H:%M:%S',
|
||||
time.localtime(calendar.timegm(time.gmtime()))))
|
||||
environment.set_env_var('_internal_start_timestamp', calendar.timegm(time.gmtime()))
|
||||
|
||||
# interval set in args is overriding configuration and default
|
||||
if args.interval:
|
||||
|
|
@ -157,7 +160,7 @@ def main():
|
|||
configuration.set_httpserver(True)
|
||||
|
||||
try:
|
||||
u = Uplink(configuration)
|
||||
u = Uplink(configuration, environment)
|
||||
except Exception as err:
|
||||
logger.error(str('[uplink] core error! {0}'.format(err)))
|
||||
sys.exit(1)
|
||||
|
|
@ -178,13 +181,13 @@ def main():
|
|||
from threading import Thread
|
||||
if configuration.get_httpserver():
|
||||
from uplink.httpserver import HTTPServer
|
||||
s = HTTPServer(configuration)
|
||||
s = HTTPServer(configuration, environment)
|
||||
st = Thread(target=s.run_server, daemon=True)
|
||||
st.start()
|
||||
|
||||
if configuration.get_speedtest():
|
||||
from uplink.speedtest import Speedtest
|
||||
se = Speedtest(configuration)
|
||||
se = Speedtest(configuration, environment)
|
||||
ste = Thread(target=se.run_speedtest, daemon=True)
|
||||
ste.start()
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue