Fix SSH port to 2222; add HTTP validation server as alternative

This commit is contained in:
2026-03-30 19:11:04 -04:00
parent c4c57a1dab
commit b9b4e2b22b
4 changed files with 161 additions and 2 deletions
+89
View File
@@ -0,0 +1,89 @@
{
"name": "MQL Settings Monitor - HTTP Simple",
"nodes": [
{
"parameters": {
"rule": {
"interval": [
{
"field": "hours",
"hoursInterval": 6
}
]
}
},
"name": "Every 6 Hours",
"type": "n8n-nodes-base.scheduleTrigger",
"typeVersion": 1,
"position": [250, 300]
},
{
"parameters": {
"requestMethod": "GET",
"url": "http://127.0.0.1:8080/validate",
"options": {
"timeout": 30000
}
},
"name": "HTTP Request - Validate",
"type": "n8n-nodes-base.httpRequest",
"typeVersion": 1,
"position": [450, 300]
},
{
"parameters": {
"conditions": {
"string": [
{
"value1": "={{ $json.status }}",
"operation": "notEqual",
"value2": "ok"
}
]
}
},
"name": "Has Issues?",
"type": "n8n-nodes-base.if",
"typeVersion": 1,
"position": [650, 300]
},
{
"parameters": {
"chatId": "={{ $env.TELEGRAM_CHAT_ID }}",
"text": "=🚨 <b>MQL Settings Issues</b>\n\n<pre>{{ $json.stdout }}</pre>\n\n⏰ {{ new Date().toLocaleString() }}"
},
"name": "Telegram Alert",
"type": "n8n-nodes-base.telegram",
"typeVersion": 1,
"position": [850, 200]
},
{
"parameters": {},
"name": "No Issues",
"type": "n8n-nodes-base.noOp",
"typeVersion": 1,
"position": [850, 400]
}
],
"connections": {
"Every 6 Hours": {
"main": [
[{ "node": "HTTP Request - Validate", "type": "main", "index": 0 }]
]
},
"HTTP Request - Validate": {
"main": [
[{ "node": "Has Issues?", "type": "main", "index": 0 }]
]
},
"Has Issues?": {
"main": [
[{ "node": "Telegram Alert", "type": "main", "index": 0 }],
[{ "node": "No Issues", "type": "main", "index": 0 }]
]
}
},
"settings": {
"executionOrder": "v1"
}
}
+2 -2
View File
@@ -23,8 +23,8 @@
{
"parameters": {
"authentication": "password",
"host": "localhost",
"port": 22,
"host": "127.0.0.1",
"port": 2222,
"username": "garfield",
"password": "=onelove01",
"command": "/home/garfield/mql-trading-bots/scripts/validate-settings.sh"
+14
View File
@@ -0,0 +1,14 @@
[Unit]
Description=MQL Validation HTTP Server
After=network.target
[Service]
Type=simple
User=garfield
WorkingDirectory=/home/garfield/mql-trading-bots
ExecStart=/usr/bin/python3 /home/garfield/mql-trading-bots/scripts/validation-server.py
Restart=always
RestartSec=5
[Install]
WantedBy=multi-user.target
+56
View File
@@ -0,0 +1,56 @@
#!/usr/bin/env python3
"""
Simple HTTP server to expose validation script for n8n
Usage: python3 validation-server.py
Access: http://localhost:8080/validate
"""
import http.server
import socketserver
import subprocess
import json
import os
PORT = 8080
REPO_DIR = "/home/garfield/mql-trading-bots"
class ValidationHandler(http.server.SimpleHTTPRequestHandler):
def do_GET(self):
if self.path == '/validate':
# Run validation script
os.chdir(REPO_DIR)
result = subprocess.run(
['./scripts/validate-settings.sh'],
capture_output=True,
text=True
)
# Build response
response = {
'status': 'ok' if result.returncode == 0 else 'error',
'code': result.returncode,
'stdout': result.stdout,
'stderr': result.stderr
}
# Send response
self.send_response(200)
self.send_header('Content-Type', 'application/json')
self.end_headers()
self.wfile.write(json.dumps(response).encode())
elif self.path == '/health':
self.send_response(200)
self.send_header('Content-Type', 'application/json')
self.end_headers()
self.wfile.write(json.dumps({'status': 'healthy'}).encode())
else:
self.send_error(404)
def log_message(self, format, *args):
# Suppress logs
pass
if __name__ == '__main__':
with socketserver.TCPServer(("127.0.0.1", PORT), ValidationHandler) as httpd:
print(f"Validation server running at http://127.0.0.1:{PORT}/validate")
httpd.serve_forever()