diff --git a/initialize.py b/initialize.py index 6ffef0a..a78a5a0 100644 --- a/initialize.py +++ b/initialize.py @@ -1,5 +1,42 @@ -from core.server.server import startServer -#import login +import threading -#login -startServer() +from core.server.server import startServer +from core.execution.createthread import buildThread +from plugins.rmass.monitors import rmassmonitor +from plugins.rmass.actions import refresh_tokens + +import login + +lifecycles ={} + +try: + lifecycles[rmassmonitor.name] = {} + lifecycles[rmassmonitor.name]["mode"] = "continuous" + thread, lifecycles = buildThread(rmassmonitor, lifecycles) +except ConnectionError: + print("Connection Error caught. Recovering") + pass + +try: + lifecycles[refresh_tokens.name] = {} + lifecycles[refresh_tokens.name]["mode"] = "continuous" + thread, lifecycles = buildThread(refresh_tokens, lifecycles) +except ConnectionError: + print("Connection Error caught. Recovering") + pass + + +#lifecycles = {} +#try: +# lifecycles[rmassmonitor.name] = lifecycles +# lifecycles[rmassmonitor.name]["mode"] = "continuous" +# thread, lifecycles = buildThread(rmassmonitor, lifecycles) +#except ConnectionError: +# print("Connection Error caught. Recovering") +# pass + +thread = threading.Thread( + target=startServer, + #args=(module, lifecycles) + ) +thread.start() \ No newline at end of file diff --git a/plugins/rmass/actions/refresh_tokens.py b/plugins/rmass/actions/refresh_tokens.py index 7b4bddd..d9c8d57 100644 --- a/plugins/rmass/actions/refresh_tokens.py +++ b/plugins/rmass/actions/refresh_tokens.py @@ -37,7 +37,6 @@ savedata = [ "refresh_token", ] -#savepath = "/rmmanager/tokens.json" savepath = os.environ["TOKEN_STORE"] outputs = { @@ -51,3 +50,39 @@ recoverPolicy = { login, ], } + +sleeptime = 120 + +#saverow = { +# "table": "credentials", +# "columns": [ +# {"rmass_token_name": "TEXT PRIMARY KEY"}, +# +# {"rmass_token_hash": "TEXT NOT NULL"}, +# ], +# "rowitems": [ +# "access_token" +# {"outputs": "access_token"}, +# "refresh_token" +# {"outputs": "refresh_token"}, +# ], +#} + +#readrow = { +# "table": "credentials", +# "columns": [ +# {"rmass_token_name": "TEXT PRIMARY KEY"}, +# {"rmass_token_hash": "TEXT NOT NULL"}, +# ], +# "searchcolumn": "rmass_token_name", +# "rowsearchvalue": [ +# "refresh_token", +# ], +# "columnnumber": 0, +# "export": { +# #0: "refresh_token", +# 1: "refresh_token", +# #2: "db_dm_room", +# #3: "db_avatar_hash", +# } +#} diff --git a/plugins/rmass/actions/setavailable.py b/plugins/rmass/actions/setavailable.py index c7e4692..9e5c1a9 100644 --- a/plugins/rmass/actions/setavailable.py +++ b/plugins/rmass/actions/setavailable.py @@ -8,10 +8,6 @@ id = "setavailable" showstatus = True -#skipstep = { -# "checkavailable": "validTo >= 3600" -#} - resolve = { "get": { "availabletime": ["availabletime"], @@ -63,4 +59,11 @@ recoverPolicy = { # "filtervalue": 3600, # "print": "Availabile time above threshold. Skipping Set Available...", # }, -#] \ No newline at end of file +#] + +loaddata = [ + "access_token", + #"refresh_token", +] + +savepath = os.environ["TOKEN_STORE"] \ No newline at end of file diff --git a/plugins/rmass/monitors/rmassmonitor.py b/plugins/rmass/monitors/rmassmonitor.py index 67a41c9..ef87001 100644 --- a/plugins/rmass/monitors/rmassmonitor.py +++ b/plugins/rmass/monitors/rmassmonitor.py @@ -15,7 +15,7 @@ isrequest = True method = "GET" -refreshrate = int(os.environ.get("MONITOR_INTERVAL", 10)) +refreshrate = int(os.environ.get("MONITOR_INTERVAL", 30)) path = "https://rentmasseur.com/api/v1/account/keeponline" @@ -59,6 +59,7 @@ filters = [ }, ] +sleeptime = 10 #prints = { # "Status": "message", @@ -68,3 +69,10 @@ filters = [ #recoverPolicy = { # KeyError: [] #} + +loaddata = [ + "access_token", + "refresh_token", +] + +savepath = os.environ["TOKEN_STORE"] \ No newline at end of file