Reestablished working state
This commit is contained in:
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -1,5 +1,5 @@
|
||||
import importlib
|
||||
from lifecyclemanager import manageLifecycle
|
||||
from core.execution.lifecyclemanager import manageLifecycle
|
||||
from .dispatchstate import buildState
|
||||
|
||||
def buildDispatch(request):
|
||||
|
||||
@@ -0,0 +1,14 @@
|
||||
import json
|
||||
|
||||
def buildResponse(module, thread, mode):
|
||||
|
||||
response = {
|
||||
"status": "success",
|
||||
"message": f"{module.name} dispatched",
|
||||
"thread": f"{thread}",
|
||||
"mode": f"{mode}",
|
||||
}
|
||||
|
||||
#responsedata = json.dumps(response).encode("utf-8")
|
||||
|
||||
return response
|
||||
@@ -1,6 +1,7 @@
|
||||
from .createdispatch import buildDispatch
|
||||
from .dispatchstate import buildState
|
||||
from core.execution.createthread import buildThread
|
||||
from .createresponse import buildResponse
|
||||
|
||||
import threading
|
||||
|
||||
@@ -14,9 +15,6 @@ def dispatchRequest(request, lifecycles):
|
||||
return lifecycles
|
||||
|
||||
else:
|
||||
threadnum, threadname, lifecycles, threadlist = buildThread(module, lifecycles)
|
||||
thread, lifecycles = buildThread(module, lifecycles)
|
||||
|
||||
#print("Active Threads")
|
||||
#print(threadlist)
|
||||
|
||||
return threadnum, threadname, lifecycles, threadlist
|
||||
return thread, lifecycles, module, mode
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import requests
|
||||
|
||||
from core import registerLifecycle
|
||||
from core.execution.lifecyclemanager import registerLifecycle
|
||||
|
||||
def filterMode(mode):
|
||||
if mode in ("continuous", "oneshot", "stop"):
|
||||
|
||||
+17
-5
@@ -1,19 +1,25 @@
|
||||
import socket
|
||||
import json
|
||||
import os
|
||||
import logging
|
||||
|
||||
from .dispatcher import dispatchRequest
|
||||
from .createresponse import buildResponse
|
||||
|
||||
port = int(os.environ.get("SERVER_PORT", 19001))
|
||||
|
||||
def startServer():
|
||||
from .dispatcher import dispatchRequest
|
||||
|
||||
server = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
|
||||
|
||||
server.bind(("127.0.0.1", 19002))
|
||||
server.bind(("0.0.0.0", port))
|
||||
|
||||
lifecycles = {}
|
||||
|
||||
server.listen()
|
||||
|
||||
logging.info(f"Server listening on port {port}")
|
||||
while True:
|
||||
connection, address = server.accept()
|
||||
logging.info("Accepting connections")
|
||||
|
||||
while True:
|
||||
data = connection.recv(4096)
|
||||
@@ -23,7 +29,13 @@ def startServer():
|
||||
# if not data:
|
||||
# break
|
||||
|
||||
dispatch = dispatchRequest(request, lifecycles)
|
||||
thread, lifecycles, module, mode = dispatchRequest(request, lifecycles)
|
||||
|
||||
response = buildResponse(module, thread, mode)
|
||||
|
||||
connection.sendall(
|
||||
json.dumps(response).encode("utf-8"),
|
||||
)
|
||||
|
||||
connection.close()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user