diff options
| author | jantuomi <jans.tuomi@gmail.com> | 2016-07-26 15:28:49 +0300 |
|---|---|---|
| committer | jantuomi <jans.tuomi@gmail.com> | 2016-07-26 15:28:49 +0300 |
| commit | d8d8745e7370ec0efa85e3f98da85f79b66c1422 (patch) | |
| tree | aabcc7560978f17a36f132639fcc247295cc6a9f /radiodiodibot | |
| parent | 392a51b858dde0c68ce93a9415c3841062a70805 (diff) | |
Add uptime service
Diffstat (limited to 'radiodiodibot')
| -rwxr-xr-x | radiodiodibot | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/radiodiodibot b/radiodiodibot index f23b9f7..903881c 100755 --- a/radiodiodibot +++ b/radiodiodibot @@ -4,13 +4,15 @@ import configparser import logging import signal import sys +import threading from project import botmanager +from project import uptimeservice def sigint_handler(signal, frame): """Exit gracefully when receiving an interrupt signal""" - print("Exiting src...") + print("Exiting radiodiodibot...") sys.exit(0) signal.signal(signal.SIGINT, sigint_handler) @@ -56,6 +58,10 @@ except: print("Please install telepot before using src.") sys.exit(1) +def run_uptime(port): + logging.info("Setting up uptime service...") + uptime_server = uptimeservice.UptimeService(int(port)) + uptime_server.start() # Entry point def main(): @@ -67,6 +73,7 @@ def main(): telegram_chat_id = config["GENERAL"]["TelegramChatID"] api_call_interval = int(config["GENERAL"]["ApiCallInterval"]) api_auth_token = config["GENERAL"]["ApiAuthToken"] + uptime_port = config["UPTIME"]["Port"] # If the user has specified the parameters as command line # arguments, use them to override the config values @@ -90,6 +97,10 @@ def main(): logging.info("Using Telegram Chat ID: {}".format(telegram_chat_id)) logging.info("Using API call interval of {} seconds.".format(api_call_interval)) + # Start uptime server if user has provided a port to bind + if uptime_port is not None: + run_uptime(uptime_port) + # Start listening manager.start() |
