diff --git a/n8n-workflow-http-simple.json b/n8n-workflow-http-simple.json new file mode 100644 index 0000000..6248db1 --- /dev/null +++ b/n8n-workflow-http-simple.json @@ -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": "=🚨 MQL Settings Issues\n\n
{{ $json.stdout }}\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"
+ }
+}
diff --git a/n8n-workflow-ssh-local.json b/n8n-workflow-ssh-local.json
index dab065f..8368588 100644
--- a/n8n-workflow-ssh-local.json
+++ b/n8n-workflow-ssh-local.json
@@ -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"
diff --git a/scripts/mql-validation.service b/scripts/mql-validation.service
new file mode 100644
index 0000000..9bb2a24
--- /dev/null
+++ b/scripts/mql-validation.service
@@ -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
diff --git a/scripts/validation-server.py b/scripts/validation-server.py
new file mode 100755
index 0000000..d9bbb9c
--- /dev/null
+++ b/scripts/validation-server.py
@@ -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()