Moved notifier into main process

This commit is contained in:
2026-04-22 14:27:36 +02:00
parent 9e1e072620
commit 3e8fb97881
3 changed files with 26 additions and 26 deletions

View File

@@ -1,3 +1,6 @@
TellMe Server (2.2.0)
* Moved the notifier into tellmesrv
TellMe Server (2.1.0) TellMe Server (2.1.0)
* Added support for GoAlert messages * Added support for GoAlert messages

View File

@@ -3,17 +3,17 @@ from flask import Flask, request, jsonify
import websocket import websocket
import json import json
import yaml import yaml
import zmq import random
from pprint import pprint from pprint import pprint
__version__ = "2.1.1" __version__ = "2.2.0"
versionstring='Taurix TellMe server v' + __version__ versionstring='Taurix TellMe server v' + __version__
app = Flask(__name__) app = Flask(__name__)
context = zmq.Context() # context = zmq.Context()
socket = context.socket(zmq.REQ) # socket = context.socket(zmq.REQ)
socket.connect("tcp://localhost:5555") # socket.connect("tcp://localhost:5555")
hooks = {} hooks = {}
with open(r'/etc/tellme/hooks.yml') as hooksfile: with open(r'/etc/tellme/hooks.yml') as hooksfile:
@@ -21,17 +21,26 @@ with open(r'/etc/tellme/hooks.yml') as hooksfile:
def sendmessage(target, message): def sendmessage(target, message):
global socket # global socket
jsonmessage = {}
jsonmessage['target'] = target
jsonmessage['message'] = message
socket.send_string(json.dumps(jsonmessage))
# Wait for a reply msg = ("%s %s" % (target, message))
reply = socket.recv_string()
print(f"Received reply: {reply}")
if reply == 'sent': # Create a unique correlation ID
command = {
"corrId": f"id{random.randint(0, 999999)}",
"cmd": msg,
}
json_command = json.dumps(command)
uri = "ws://localhost:5080"
ws = websocket.create_connection(uri)
ws.send(json_command) # Send message to WebSocket
responsejson = ws.recv() # Receive response
response = json.loads(responsejson)
ws.close()
if response is not None:
return True return True
else: else:
return False return False

View File

@@ -1,12 +0,0 @@
[Unit]
Description=Tellme Notifier
After=network.target
[Service]
User=tellme
WorkingDirectory=/opt/tellme
ExecStart=python3 notifier.py
Restart=always
[Install]
WantedBy=multi-user.target