mirror of
https://github.com/jokob-sk/NetAlertX.git
synced 2025-12-07 09:36:05 -08:00
GraphQl 0.124 - Running server check
This commit is contained in:
@@ -12,7 +12,7 @@ INSTALL_PATH="/app"
|
||||
sys.path.extend([f"{INSTALL_PATH}/server"])
|
||||
|
||||
from logger import mylog
|
||||
from helper import get_setting_value, timeNowTZ
|
||||
from helper import get_setting_value, timeNowTZ, updateState
|
||||
from notification import write_notification
|
||||
|
||||
app = Flask(__name__)
|
||||
@@ -26,7 +26,7 @@ def graphql_endpoint():
|
||||
token = request.headers.get("Authorization")
|
||||
if token != f"Bearer {API_TOKEN}":
|
||||
mylog('verbose', [f'[graphql_server] Unauthorized access attempt'])
|
||||
|
||||
|
||||
return jsonify({"error": "Unauthorized"}), 401
|
||||
|
||||
data = request.get_json()
|
||||
@@ -42,8 +42,16 @@ def graphql_endpoint():
|
||||
def start_server():
|
||||
"""Function to start the GraphQL server in a background thread."""
|
||||
mylog('verbose', [f'[graphql_server] Starting on port: {GRAPHQL_PORT}'])
|
||||
|
||||
# Start the Flask app in a separate thread
|
||||
thread = threading.Thread(target=lambda: app.run(host="0.0.0.0", port=GRAPHQL_PORT, debug=True, use_reloader=False))
|
||||
thread.start()
|
||||
|
||||
state = updateState("GraphQL: Starting", None, None, None, None)
|
||||
|
||||
if state.graphQLServerStarted == 0:
|
||||
|
||||
# Start the Flask app in a separate thread
|
||||
thread = threading.Thread(target=lambda: app.run(host="0.0.0.0", port=GRAPHQL_PORT, debug=True, use_reloader=False))
|
||||
thread.start()
|
||||
|
||||
# updateState(newState, settingsSaved = None (timestamp), settingsImported = None (timestamp), showSpinner = False (1/0), graphQLServerStarted = False (1/0))
|
||||
# update GraphQL = started
|
||||
state = updateState("Process: Wait", None, None, None, 1)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user