Compare commits
16
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
4ccd44937f | ||
|
|
53021d381e | ||
|
|
433c1e4b77 | ||
|
|
c230939b45 | ||
|
|
2c2a41fafb | ||
|
|
b3094f75a9 | ||
|
|
b5591ade62 | ||
|
|
fe2a54ca00 | ||
|
|
f2df751294 | ||
|
|
50cb0e0924 | ||
|
|
dafde0a805 | ||
|
|
f10ab522c9 | ||
|
|
476ef608f3 | ||
|
|
63330c9ecd | ||
|
|
b59401c64f | ||
|
|
4189812957 |
@@ -1,8 +0,0 @@
|
||||
.git
|
||||
.gitignore
|
||||
__pycache__/
|
||||
*.pyc
|
||||
*.pyo
|
||||
*.pyd
|
||||
.venv/
|
||||
venv/
|
||||
@@ -24,3 +24,9 @@ savedata/
|
||||
|
||||
# Logs
|
||||
*.log
|
||||
|
||||
#Trash and unused files
|
||||
trash/
|
||||
|
||||
#Docker files
|
||||
.dockerignore
|
||||
@@ -2,8 +2,6 @@ import logging
|
||||
|
||||
from core.apirequest import executeRequest
|
||||
from core.runtime.runtimecontract import buildRuntimeAttr, buildPreRuntimeAttr
|
||||
#from core.runtime.stopsignals import addStopSignal
|
||||
|
||||
|
||||
def buildAction (action, outputs):
|
||||
action_log = True
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import threading
|
||||
import logging
|
||||
|
||||
from .lifecyclemanager import manageLifecycle
|
||||
|
||||
@@ -12,4 +13,6 @@ def buildThread(module):
|
||||
|
||||
thread.start()
|
||||
|
||||
logging.info(f"THREAD STARTED, {thread}")
|
||||
|
||||
return thread
|
||||
|
||||
@@ -3,17 +3,16 @@ from core.execution.operation import buildOperation
|
||||
from core.execution.monitor import buildMonitor
|
||||
#from core.runtime import manageFailure
|
||||
from core.execution.recursive import buildRecursive
|
||||
from core.runtime.createruntime import outputs
|
||||
|
||||
def executeContract(module, outputs):
|
||||
def executeContract(module):
|
||||
|
||||
if module.kind == "operation":
|
||||
|
||||
responses = buildOperation(module, outputs)
|
||||
|
||||
return responses
|
||||
|
||||
elif module.kind == "action":
|
||||
|
||||
response = buildAction(module, outputs)
|
||||
|
||||
return response
|
||||
|
||||
@@ -6,9 +6,10 @@ from core.apirequest.execute import getSession
|
||||
from core.execution.lifecyclemanager.lifecycleregistry import registerLifecycle
|
||||
|
||||
lifecycles = {}
|
||||
outputs = {}
|
||||
#outputs = {}
|
||||
|
||||
def manageLifecycle(module):
|
||||
from core.runtime.createruntime import outputs
|
||||
lifecycle_log = os.environ.get("LOGS_LIFECYCLE", "false").lower() == "true"
|
||||
|
||||
registerLifecycle (module, lifecycles)
|
||||
@@ -17,7 +18,7 @@ def manageLifecycle(module):
|
||||
while lifecycles[module.name]["mode"] == "continuous":
|
||||
lifecycles[module.name]["state"] = "active"
|
||||
|
||||
response = executeContract(module, outputs)
|
||||
executeContract(module)
|
||||
|
||||
if lifecycle_log:
|
||||
print(f"{module.name} thread {lifecycles[module.name][module.name]} running in {lifecycles[module.name]['mode']} mode")
|
||||
@@ -34,7 +35,7 @@ def manageLifecycle(module):
|
||||
print(f"{module.name} thread {lifecycles[module.name][module.name]} running in {lifecycles[module.name]['mode']} mode")
|
||||
print(lifecycles)
|
||||
|
||||
response = executeContract(module, outputs)
|
||||
response = executeContract(module)
|
||||
|
||||
lifecycles[module.name]["state"] = "stopped"
|
||||
|
||||
|
||||
@@ -23,14 +23,17 @@ def registerLifecycle(module, lifecycles):
|
||||
#print(lifecycles)
|
||||
|
||||
if "mode" not in lifecycles[module.name]:
|
||||
if hasattr(module, "mode"):
|
||||
mode = getattr(module, "mode")
|
||||
lifecycles[module.name]["mode"] = mode
|
||||
else:
|
||||
lifecycles[module.name]["mode"] = "oneshot"
|
||||
|
||||
if lifecycles[module.name]["mode"] == "continuous":
|
||||
lifecycles[module.name]["refresh_rate"] = module.sleeptime
|
||||
|
||||
if not lifecycles[module.name]["mode"]:
|
||||
lifecycles[module.name]["mode"] = "oneshot"
|
||||
#if lifecycles[module.name]["mode"] == {}:
|
||||
# lifecycles[module.name]["mode"] = "oneshot"
|
||||
|
||||
#lifecycles[module.name][registryname] = registryvalue
|
||||
|
||||
|
||||
@@ -31,11 +31,14 @@ def buildMonitor(monitor, outputs):
|
||||
buildOutput(response, monitor, outputs)
|
||||
|
||||
if match:
|
||||
from core.execution.executioncontract import executeContract
|
||||
from core.execution.createthread import buildThread
|
||||
#from core.execution.executioncontract import executeContract
|
||||
|
||||
logging.info(filter.get("print"))
|
||||
module = filter["execute"]
|
||||
#module = filter["execute"]
|
||||
|
||||
response = executeContract(filter["execute"], outputs)
|
||||
#response = executeContract(filter["execute"], outputs)
|
||||
|
||||
thread = buildThread(filter["execute"])
|
||||
|
||||
return response
|
||||
@@ -8,18 +8,18 @@ from core.runtime.stopsignals import checkDependency
|
||||
from core.execution import processregistry
|
||||
from core.console import console
|
||||
|
||||
outputs = {}
|
||||
#outputs = {}
|
||||
|
||||
def buildOperation(definition, outputs):
|
||||
|
||||
process_log = True
|
||||
|
||||
from core.execution.executioncontract import executeContract
|
||||
|
||||
actions = definition.actions
|
||||
currentOp = processregistry.registerProcess(definition)
|
||||
|
||||
responses = []
|
||||
|
||||
currentOp = processregistry.registerProcess(definition)
|
||||
|
||||
if getattr(definition, "track", False):
|
||||
actions = track(
|
||||
actions,
|
||||
@@ -38,7 +38,9 @@ def buildOperation(definition, outputs):
|
||||
if action.kind == "action":
|
||||
currentOp[action.name] = {}
|
||||
|
||||
response = executeContract(action, outputs)
|
||||
from core.execution.executioncontract import executeContract
|
||||
|
||||
response = executeContract(action)
|
||||
|
||||
responses.append(response)
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@ processes = {}
|
||||
registeredOp = {}
|
||||
|
||||
def registerProcess(module):
|
||||
global registeredOp
|
||||
#global registeredOp
|
||||
|
||||
processes[module.name] = {}
|
||||
|
||||
|
||||
@@ -20,7 +20,7 @@ def buildRecursive(definition, outputs):
|
||||
currentOp = processregistry.registerProcess(definition)
|
||||
|
||||
responses = []
|
||||
from core.execution.executioncontract import executeContract
|
||||
|
||||
recursiveset = definition.recursiveset["actions"]
|
||||
|
||||
source = definition.recursiveset["source"]
|
||||
@@ -53,7 +53,9 @@ def buildRecursive(definition, outputs):
|
||||
if job.kind == "action":
|
||||
currentOp[job.name] = {}
|
||||
|
||||
response = executeContract(job, outputs)
|
||||
from core.execution.executioncontract import executeContract
|
||||
|
||||
response = executeContract(job)
|
||||
responses.append(response)
|
||||
|
||||
if job.kind == "action":
|
||||
|
||||
@@ -0,0 +1,4 @@
|
||||
outputs = {}
|
||||
|
||||
def getOuputs():
|
||||
return outputs
|
||||
@@ -20,9 +20,9 @@ def buildFirewall(listener, outputs):
|
||||
status_code = filter.get("status_code", 200)
|
||||
|
||||
if filter.get("execute", False):
|
||||
from core.apirequest.execute import executeRequest
|
||||
from core.execution.createthread import buildThread
|
||||
|
||||
response = executeRequest(filter["execute"], outputs, resolved)
|
||||
thread = buildThread(filter["execute"])
|
||||
|
||||
if firewall_log:
|
||||
logging.info(filter.get("print"))
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import os
|
||||
import logging
|
||||
|
||||
def resolveItem(action, item):
|
||||
#resolver_log = os.environ.get("LOGS_RESOLVER", "false").lower() == "true"
|
||||
@@ -17,7 +18,7 @@ def resolveItem(action, item):
|
||||
|
||||
except (KeyError, IndexError) as error:
|
||||
if resolver_log:
|
||||
print(f"Resolver target key/index {error} not found during {action.name}")
|
||||
logging.info(f"Resolver target key/index {error} not found during {action.name}")
|
||||
target = None
|
||||
|
||||
resolved[label] = target
|
||||
|
||||
@@ -1,9 +1,15 @@
|
||||
import logging
|
||||
|
||||
from core.apirequest import executeRequest
|
||||
from core.execution import processregistry
|
||||
|
||||
def responsePolicy(response, action, outputs, resolved):
|
||||
if hasattr(action, "responsepolicy"):
|
||||
#if processregistry.registeredOp:
|
||||
#currentOp = processregistry.registeredOp
|
||||
#print(registeredOp[action.name]["response"])
|
||||
#print(currentOp)
|
||||
|
||||
if not response.ok:
|
||||
logging.warning(f"{response} during {action.name}")
|
||||
|
||||
@@ -11,11 +17,19 @@ def responsePolicy(response, action, outputs, resolved):
|
||||
if policy["statuscode"] == response.status_code:
|
||||
logging.warning(policy["print"])
|
||||
|
||||
newresponse = executeRequest(policy["execute"], outputs, resolved)
|
||||
from core.execution.executioncontract import executeContract
|
||||
executeContract(policy["execute"])
|
||||
|
||||
#newresponse = executeRequest(action, outputs, resolved)
|
||||
|
||||
if policy["response_update"]:
|
||||
logging.info("Updating response")
|
||||
print("Updating response")
|
||||
newresponse = executeRequest(action, outputs, resolved)
|
||||
|
||||
#response = newresponse
|
||||
if processregistry.registeredOp:
|
||||
response = processregistry.registeredOp[action.name]["response"]
|
||||
else:
|
||||
response = newresponse
|
||||
|
||||
break
|
||||
|
||||
@@ -3,17 +3,10 @@ import logging
|
||||
|
||||
from core.runtime.outputs import buildOutput
|
||||
from core.runtime.firewall import buildFirewall
|
||||
from core.runtime.createruntime import outputs
|
||||
|
||||
|
||||
def buildListener(listener, self):
|
||||
|
||||
if self.path == "/_matrix/app/v1/ping":
|
||||
self.send_response(200)
|
||||
self.send_header("Content-Type", "application/json")
|
||||
self.end_headers()
|
||||
self.wfile.write(b"{}")
|
||||
return
|
||||
|
||||
if self.path.startswith(listener.acceptpath):
|
||||
|
||||
#Prints can used buildlog for listener runtime
|
||||
@@ -24,21 +17,20 @@ def buildListener(listener, self):
|
||||
data = self.rfile.read(content_length)
|
||||
request = json.loads(data)
|
||||
|
||||
outputs = {}
|
||||
#outputs = {}
|
||||
|
||||
buildOutput(data, listener, outputs)
|
||||
|
||||
allow, status_code = buildFirewall(listener, outputs)
|
||||
|
||||
if allow:
|
||||
#from core.execution.createthread import buildThread
|
||||
from core.execution.executioncontract import executeContract
|
||||
|
||||
#Print allowed items for logging purposes
|
||||
logging.info(outputs["firewall_allowed"])
|
||||
|
||||
#Process and forward to RMASS
|
||||
responses = executeContract(listener.execute, outputs)
|
||||
|
||||
#thread = buildThread(listener.execute)
|
||||
executeContract(listener.execute)
|
||||
|
||||
|
||||
self.send_response(status_code)
|
||||
|
||||
+14
-1
@@ -8,13 +8,26 @@ from .dispatcher import dispatchRequest
|
||||
from .createresponse import buildResponse
|
||||
from plugins.rmass.listeners import synapselistener
|
||||
from core.server.createlistener import buildListener
|
||||
#from plugins.rmass.actions import pingsynapse
|
||||
from plugins.rmass.actions import synapsesetbridgeonline
|
||||
|
||||
port = int(os.environ.get("SERVER_PORT", 19001))
|
||||
|
||||
|
||||
class RequestHandler(BaseHTTPRequestHandler):
|
||||
def do_POST(self):
|
||||
if self.path == "/_matrix/app/v1/ping":
|
||||
|
||||
from core.execution.createthread import buildThread
|
||||
thread = buildThread(synapsesetbridgeonline)
|
||||
|
||||
self.send_response(200)
|
||||
self.send_header("Content-Type", "application/json")
|
||||
self.send_header("Content-Length", "2")
|
||||
self.end_headers()
|
||||
self.wfile.write(b"{}")
|
||||
return
|
||||
|
||||
else:
|
||||
#lifecycles = {}
|
||||
print("POST request received")
|
||||
|
||||
|
||||
+15
-9
@@ -5,7 +5,8 @@ import os
|
||||
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
|
||||
from plugins.rmass.operations import token_update
|
||||
from plugins.rmass.actions import pingsynapse
|
||||
|
||||
from core.console import console
|
||||
from rich.logging import RichHandler
|
||||
@@ -27,16 +28,21 @@ logging.basicConfig(
|
||||
import login
|
||||
import synapsemessagepush
|
||||
|
||||
rmassmonitor.mode = "continuous"
|
||||
refresh_tokens.mode = "continuous"
|
||||
|
||||
thread = buildThread(rmassmonitor)
|
||||
|
||||
thread = buildThread(refresh_tokens)
|
||||
|
||||
thread = threading.Thread(
|
||||
target=startServer,
|
||||
#args=(module, lifecycles)
|
||||
name="RMASS Bridge Server"
|
||||
)
|
||||
thread.start()
|
||||
|
||||
pingsynapse.mode = "continuous"
|
||||
rmassmonitor.mode = "continuous"
|
||||
token_update.mode = "continuous"
|
||||
#refresh_tokens.mode = "continuous"
|
||||
|
||||
thread = buildThread(rmassmonitor)
|
||||
|
||||
#thread = buildThread(refresh_tokens)
|
||||
|
||||
thread = buildThread(token_update)
|
||||
|
||||
thread = buildThread(pingsynapse)
|
||||
@@ -1,11 +1,13 @@
|
||||
name = "Synapse Wake"
|
||||
name = "Synapse Ping"
|
||||
|
||||
kind = "action"
|
||||
|
||||
alias = "synapseping"
|
||||
alias = "pingsynapse"
|
||||
|
||||
showstatus = True
|
||||
|
||||
sleeptime = 15
|
||||
|
||||
isrequest = True
|
||||
|
||||
method = "POST"
|
||||
|
||||
@@ -5,6 +5,8 @@ name = "Token refresh"
|
||||
|
||||
kind = "action"
|
||||
|
||||
alias = "refresh_tokens"
|
||||
|
||||
showstatus = True
|
||||
|
||||
method = "GET"
|
||||
@@ -44,6 +46,15 @@ outputs = {
|
||||
"refresh_token": "refreshToken",
|
||||
}
|
||||
|
||||
responsepolicy = [
|
||||
{
|
||||
"statuscode": 403,
|
||||
"print": "Refreshing stale tokens...",
|
||||
"execute": login,
|
||||
"response_update": False,
|
||||
}
|
||||
]
|
||||
|
||||
recoverPolicy = {
|
||||
FileNotFoundError: [
|
||||
getcsrf,
|
||||
|
||||
@@ -10,15 +10,8 @@ showstatus = True
|
||||
|
||||
resolve = {
|
||||
"get": {
|
||||
"sender": ["room_name"],
|
||||
"event_id": ["outmessageitem", "event_id"],
|
||||
"room_id": ["outmessageitem", "room_id"],
|
||||
},
|
||||
"deconstruct": {
|
||||
"sender" : [
|
||||
"#rmass_dm_",
|
||||
":loxthelion.com",
|
||||
],
|
||||
"event_id": ["events", 0, "event_id"],
|
||||
"room_id": ["events", 0, "room_id"],
|
||||
},
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,36 @@
|
||||
name = "Set RMASS Bridge Online"
|
||||
|
||||
kind = "action"
|
||||
|
||||
alias = "setrmassbridgeonline"
|
||||
|
||||
showstatus = True
|
||||
|
||||
#sleeptime = 15
|
||||
|
||||
isrequest = True
|
||||
|
||||
method = "PUT"
|
||||
|
||||
path = [
|
||||
"https://loxthelion.com/_matrix/client/v3/presence/@rmass_bridge:loxthelion.com/status",
|
||||
]
|
||||
|
||||
headers = {
|
||||
"Authorization": {
|
||||
"os": "AS_TOKEN",
|
||||
"prefix": "Bearer ",
|
||||
},
|
||||
"Content-Type": "application/json",
|
||||
}
|
||||
|
||||
keys = [
|
||||
{
|
||||
"keytitle": "presence",
|
||||
"keyvalue": "online",
|
||||
},
|
||||
{
|
||||
"keytitle": "status_msg",
|
||||
"keyvalue": "RMASS Bridge Connected",
|
||||
},
|
||||
]
|
||||
@@ -1,6 +1,6 @@
|
||||
from plugins.rmass.actions import getcsrf, login
|
||||
|
||||
name = "Login"
|
||||
name = "Login Operation"
|
||||
|
||||
kind = "operation"
|
||||
|
||||
|
||||
@@ -0,0 +1,13 @@
|
||||
import os
|
||||
|
||||
from plugins.rmass.actions import refresh_tokens
|
||||
|
||||
name = "Token Refresh Operation"
|
||||
|
||||
kind = "operation"
|
||||
|
||||
actions = [
|
||||
refresh_tokens,
|
||||
]
|
||||
|
||||
sleeptime = os.environ.get("TOKEN_REFRESH_RATE", 105)
|
||||
@@ -1,5 +0,0 @@
|
||||
from plugins import rmass
|
||||
from core.operation.operation import buildOperation
|
||||
|
||||
outputs = buildOperation(rmass.checkavailableoperation)
|
||||
|
||||
@@ -1,17 +0,0 @@
|
||||
import importlib
|
||||
from lifecyclemanager import manageLifecycle
|
||||
from dispatchstate import buildState
|
||||
|
||||
def buildDispatch(request):
|
||||
dispatch = []
|
||||
|
||||
for key in request["module"]:
|
||||
dispatch.append(request["module"][key])
|
||||
|
||||
resolveddispatch = "plugins."+ ".".join(dispatch)
|
||||
|
||||
module = importlib.import_module(resolveddispatch)
|
||||
|
||||
mode = request.get("mode", "oneshot")
|
||||
|
||||
return module, mode
|
||||
@@ -1,30 +0,0 @@
|
||||
import threading
|
||||
from lifecycleregistry import registerLifecycle
|
||||
from lifecyclemanager import manageLifecycle
|
||||
|
||||
threadlist = []
|
||||
threadnum = 0
|
||||
|
||||
def buildThread(module, lifecycles):
|
||||
global threadnum
|
||||
threadnum += 1
|
||||
|
||||
threadname = f"thread.{threadnum}"
|
||||
|
||||
thread = threading.Thread(
|
||||
target=manageLifecycle,
|
||||
args=(module, lifecycles)
|
||||
)
|
||||
thread.start()
|
||||
|
||||
registryname = threadname
|
||||
registryvalue = thread
|
||||
|
||||
lifecycles = registerLifecycle (module, lifecycles, registryname, registryvalue)
|
||||
|
||||
threadlist.append(thread)
|
||||
|
||||
print(threadlist)
|
||||
print(lifecycles)
|
||||
|
||||
return threadnum, threadname, lifecycles, threadlist
|
||||
@@ -1,22 +0,0 @@
|
||||
from createdispatch import buildDispatch
|
||||
from createthread import buildThread
|
||||
from dispatchstate import buildState
|
||||
|
||||
import threading
|
||||
|
||||
def dispatchRequest(request, lifecycles):
|
||||
|
||||
module, mode = buildDispatch(request)
|
||||
|
||||
mode, lifecycles = buildState(module, mode, lifecycles)
|
||||
|
||||
if mode == "stop":
|
||||
return lifecycles
|
||||
|
||||
else:
|
||||
threadnum, threadname, lifecycles, threadlist = buildThread(module, lifecycles)
|
||||
|
||||
#print("Active Threads")
|
||||
#print(threadlist)
|
||||
|
||||
return threadnum, threadname, lifecycles, threadlist
|
||||
@@ -1,41 +0,0 @@
|
||||
import requests
|
||||
|
||||
from lifecycleregistry import registerLifecycle
|
||||
|
||||
def filterMode(mode):
|
||||
if mode in ("continuous", "oneshot", "stop"):
|
||||
state = mode
|
||||
return state
|
||||
else: raise ValueError(f"Unsupported lifecycle mode: {mode}")
|
||||
|
||||
def buildState(module, mode, lifecycles):
|
||||
state = filterMode(mode)
|
||||
|
||||
registryvalue = state
|
||||
registryname = "mode"
|
||||
|
||||
if state != "stop":
|
||||
lifecycles = registerLifecycle(module, lifecycles, registryname, registryvalue)
|
||||
|
||||
elif state == "stop":
|
||||
if not module.name in lifecycles:
|
||||
|
||||
print(f"No registered lifecycle: {module.name}")
|
||||
|
||||
return None
|
||||
|
||||
elif "mode" in lifecycles[module.name] != "stop":
|
||||
lifecycles = registerLifecycle(module, lifecycles, registryname, registryvalue)
|
||||
|
||||
print(f"Stopping lifecycle: {module.name}")
|
||||
|
||||
#elif mode == "oneshot":
|
||||
#registryvalue = {"mode": "oneshot"}
|
||||
#lifecycles = registerLifecycle(module, lifecycles, registryname, registryvalue)
|
||||
|
||||
# else:
|
||||
#raise ValueError(f"Unsupported lifecycle mode: {mode}")
|
||||
|
||||
#state = registryvalue
|
||||
|
||||
return state, lifecycles
|
||||
@@ -1,25 +0,0 @@
|
||||
import time
|
||||
|
||||
from core.execution.operation import buildOperation
|
||||
from core.execution.action import buildAction
|
||||
from core import executeContract
|
||||
|
||||
def manageLifecycle(module, lifecycles): #lifecycles, state):
|
||||
#print(lifecycles[module.name]["mode"])
|
||||
|
||||
if lifecycles[module.name]["mode"] == "continuous":
|
||||
while lifecycles[module.name]["mode"] == "continuous":
|
||||
print(lifecycles)
|
||||
|
||||
outputs = executeContract(module, None, None)
|
||||
|
||||
#print(lifecycles)
|
||||
|
||||
time.sleep(module.sleeptime)
|
||||
|
||||
elif lifecycles[module.name]["mode"] == "oneshot":
|
||||
print(lifecycles)
|
||||
outputs = executeContract(module, None, None)
|
||||
|
||||
#print(lifecycles)
|
||||
return
|
||||
@@ -1,8 +0,0 @@
|
||||
def registerLifecycle(module, lifecycles, registryname, registryvalue):
|
||||
if module.name not in lifecycles:
|
||||
lifecycles[module.name] = {}
|
||||
|
||||
|
||||
lifecycles[module.name][registryname] = registryvalue
|
||||
|
||||
return lifecycles
|
||||
@@ -1,4 +0,0 @@
|
||||
from plugins import rmass
|
||||
from operation import buildOperation
|
||||
|
||||
outputs = buildOperation(rmass.checkavailableoperation)
|
||||
@@ -1,4 +0,0 @@
|
||||
from core.manager.manager import buildManager
|
||||
from plugins import rmass
|
||||
|
||||
outputs = buildManager(rmass.manager)
|
||||
@@ -1,29 +0,0 @@
|
||||
import socket
|
||||
import json
|
||||
from dispatcher import dispatchRequest
|
||||
#from createthread import buildThread
|
||||
|
||||
server = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
|
||||
|
||||
server.bind(("127.0.0.1", 19002))
|
||||
|
||||
lifecycles = {}
|
||||
|
||||
server.listen()
|
||||
|
||||
while True:
|
||||
connection, address = server.accept()
|
||||
|
||||
while True:
|
||||
data = connection.recv(4096)
|
||||
|
||||
request = json.loads(data)
|
||||
|
||||
# if not data:
|
||||
# break
|
||||
|
||||
dispatch = dispatchRequest(request, lifecycles)
|
||||
|
||||
connection.close()
|
||||
|
||||
# server.close()
|
||||
Reference in New Issue
Block a user