Add "RUN_ONLY_ONCE" option
parent
a178d230de
commit
916b16b12c
|
|
@ -9,6 +9,9 @@ DEBUG = "False"
|
||||||
## Debugging level, "info" is default, "debug" is more verbose
|
## Debugging level, "info" is default, "debug" is more verbose
|
||||||
DEBUG_LEVEL = "info"
|
DEBUG_LEVEL = "info"
|
||||||
|
|
||||||
|
## If set to true then the script will only run once and then exit
|
||||||
|
RUN_ONLY_ONCE = "False"
|
||||||
|
|
||||||
## How often to run the script in seconds
|
## How often to run the script in seconds
|
||||||
SLEEP_DURATION = "3600"
|
SLEEP_DURATION = "3600"
|
||||||
|
|
||||||
|
|
@ -27,7 +30,7 @@ LOGFILE = "log.log"
|
||||||
## Comma separated for multiple options
|
## Comma separated for multiple options
|
||||||
#BLACKLIST_LIBRARY = ""
|
#BLACKLIST_LIBRARY = ""
|
||||||
#WHITELIST_LIBRARY = ""
|
#WHITELIST_LIBRARY = ""
|
||||||
#BLACKLIST_LIBRARY_TYPE = ""
|
#BLACKLIST_LIBRARY_TYPE = ""
|
||||||
#WHITELIST_LIBRARY_TYPE = ""
|
#WHITELIST_LIBRARY_TYPE = ""
|
||||||
#BLACKLIST_USERS = ""
|
#BLACKLIST_USERS = ""
|
||||||
WHITELIST_USERS = "testuser1,testuser2"
|
WHITELIST_USERS = "testuser1,testuser2"
|
||||||
|
|
|
||||||
|
|
@ -365,6 +365,7 @@ def main_loop():
|
||||||
|
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
|
run_only_once = str_to_bool(os.getenv("RUN_ONLY_ONCE", "False"))
|
||||||
sleep_duration = float(os.getenv("SLEEP_DURATION", "3600"))
|
sleep_duration = float(os.getenv("SLEEP_DURATION", "3600"))
|
||||||
times = []
|
times = []
|
||||||
while True:
|
while True:
|
||||||
|
|
@ -377,6 +378,9 @@ def main():
|
||||||
if len(times) > 0:
|
if len(times) > 0:
|
||||||
logger(f"Average time: {sum(times) / len(times)}", 0)
|
logger(f"Average time: {sum(times) / len(times)}", 0)
|
||||||
|
|
||||||
|
if run_only_once:
|
||||||
|
break
|
||||||
|
|
||||||
logger(f"Looping in {sleep_duration}")
|
logger(f"Looping in {sleep_duration}")
|
||||||
sleep(sleep_duration)
|
sleep(sleep_duration)
|
||||||
|
|
||||||
|
|
@ -389,6 +393,9 @@ def main():
|
||||||
|
|
||||||
logger(traceback.format_exc(), 2)
|
logger(traceback.format_exc(), 2)
|
||||||
|
|
||||||
|
if run_only_once:
|
||||||
|
break
|
||||||
|
|
||||||
logger(f"Retrying in {sleep_duration}", log_type=0)
|
logger(f"Retrying in {sleep_duration}", log_type=0)
|
||||||
sleep(sleep_duration)
|
sleep(sleep_duration)
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue