wip
This commit is contained in:
parent
105c18ba14
commit
72ddf7a3ee
3 changed files with 29 additions and 3 deletions
20
agent.py
20
agent.py
|
@ -13,16 +13,18 @@ from datetime import datetime, timedelta
|
|||
from watchdog.observers import Observer
|
||||
from watchdog.events import FileSystemEventHandler
|
||||
from dotenv import load_dotenv
|
||||
import urllib3
|
||||
|
||||
# Load environment variables
|
||||
load_dotenv()
|
||||
|
||||
# Fixed configuration
|
||||
CADDYFILE_PATH = "/app/Caddyfile" # Fixed internal path
|
||||
DASHBOARD_URL = os.getenv('DASHBOARD_URL')
|
||||
DASHBOARD_URL = os.getenv('DASHBOARD_URL', 'http://caddydb-server:5000/api/update')
|
||||
SERVER_NAME = os.getenv('SERVER_NAME', socket.gethostname())
|
||||
API_KEY = os.getenv('API_KEY')
|
||||
CHECK_INTERVAL = int(os.getenv('CHECK_INTERVAL', '60'))
|
||||
VERIFY_SSL = os.getenv('VERIFY_SSL', 'true').lower() == 'true'
|
||||
|
||||
# Setup logging
|
||||
logging.basicConfig(
|
||||
|
@ -31,6 +33,19 @@ logging.basicConfig(
|
|||
)
|
||||
logger = logging.getLogger('caddy-agent')
|
||||
|
||||
# Debug configuration
|
||||
logger.info(f"Starting Caddy agent with configuration:")
|
||||
logger.info(f"- DASHBOARD_URL: {DASHBOARD_URL}")
|
||||
logger.info(f"- SERVER_NAME: {SERVER_NAME}")
|
||||
logger.info(f"- CADDYFILE_PATH: {CADDYFILE_PATH}")
|
||||
logger.info(f"- VERIFY_SSL: {VERIFY_SSL}")
|
||||
logger.info(f"- API_KEY set: {'Yes' if API_KEY else 'No'}")
|
||||
|
||||
# Disable SSL warnings if verification is disabled
|
||||
if not VERIFY_SSL:
|
||||
urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning)
|
||||
logger.warning("SSL verification is disabled - this is insecure!")
|
||||
|
||||
# Validate required configuration
|
||||
if not os.path.exists(CADDYFILE_PATH):
|
||||
logger.error(f"Caddyfile not found at {CADDYFILE_PATH}")
|
||||
|
@ -128,7 +143,8 @@ def send_update(force=False):
|
|||
DASHBOARD_URL,
|
||||
json=data,
|
||||
headers=headers,
|
||||
timeout=10 # Set a reasonable timeout
|
||||
timeout=10, # Set a reasonable timeout
|
||||
verify=VERIFY_SSL # Control SSL verification
|
||||
)
|
||||
|
||||
if response.status_code == 200:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue