diff --git a/README.md b/README.md index fcd2c00e..b51df993 100644 --- a/README.md +++ b/README.md @@ -78,7 +78,7 @@ services: - sh - -c # Customize network ('mainnet' or 'testnet') and RPC address/port if needed - - python initialize.py -net 'mainnet' -rpc '127.0.0.1:10009' -wn && python controller.py runserver 0.0.0.0:8889 > /var/log/lndg-controller.log 2>&1 + - python initialize.py -net 'mainnet' -rpc '127.0.0.1:10009' -wn && python controller.py runserver 0.0.0.0:8889 # Use host network mode for simplicity, adjust if needed network_mode: "host" ``` diff --git a/docker-compose.yaml b/docker-compose.yaml index 82bb591f..8efbdfe2 100644 --- a/docker-compose.yaml +++ b/docker-compose.yaml @@ -7,6 +7,6 @@ services: command: - sh - -c - - python initialize.py -net 'mainnet' -rpc 'localhost:10009' -wn && python controller.py runserver 0.0.0.0:8000 > /app/data/lndg-controller.log 2>&1 + - python initialize.py -net 'mainnet' -rpc 'localhost:10009' -wn && python controller.py runserver 0.0.0.0:8000 ports: - 8889:8000 \ No newline at end of file diff --git a/gui/views.py b/gui/views.py index 4e980cfa..41273242 100644 --- a/gui/views.py +++ b/gui/views.py @@ -235,7 +235,7 @@ def logs(request): try: count = request.GET.get('tail', 20) grep = request.GET.get('grep', None) - logfile = 'data/lndg-controller.log' + logfile = path.join(settings.BASE_DIR, 'data/lndg-controller.log') file_size = path.getsize(logfile)-2 if file_size == 0: logs = ['Logs are empty....'] diff --git a/initialize.py b/initialize.py index 513de730..673a1102 100644 --- a/initialize.py +++ b/initialize.py @@ -189,7 +189,7 @@ def write_settings(node_ip, lnd_tls_path, lnd_macaroon_path, lnd_database_path, 'app-file': { 'level': 'INFO', 'class': 'logging.handlers.RotatingFileHandler', - 'filename': 'data/lndg-controller.log', + 'filename': os.path.join(BASE_DIR, 'data/lndg-controller.log'), 'maxBytes': 25*(1024*1024), 'backupCount': 5, 'formatter': 'verbose', @@ -197,7 +197,7 @@ def write_settings(node_ip, lnd_tls_path, lnd_macaroon_path, lnd_database_path, 'web-file': { 'level': 'INFO', 'class': 'logging.handlers.RotatingFileHandler', - 'filename': 'data/lndg-web.log', + 'filename': os.path.join(BASE_DIR, 'data/lndg-web.log'), 'maxBytes': 25*(1024*1024), 'backupCount': 5, 'formatter': 'verbose', diff --git a/systemd.md b/systemd.md index 4b4a52f1..fc61bc18 100644 --- a/systemd.md +++ b/systemd.md @@ -13,9 +13,10 @@ Description=Backend Controller For Lndg Environment=PYTHONUNBUFFERED=1 User= Group= +WorkingDirectory=/home//lndg ExecStart=/home//lndg/.venv/bin/python /home//lndg/controller.py -StandardOutput=append:/var/log/lndg-controller.log -StandardError=append:/var/log/lndg-controller.log +StandardOutput=journal +StandardError=journal Restart=always RestartSec=60s [Install] diff --git a/systemd.sh b/systemd.sh index c774df67..d1eb98b4 100644 --- a/systemd.sh +++ b/systemd.sh @@ -34,9 +34,10 @@ Description=Run Backend Controller For Lndg Environment=PYTHONUNBUFFERED=1 User=$INSTALL_USER Group=$INSTALL_USER +WorkingDirectory=$LNDG_DIR ExecStart=$LNDG_DIR/.venv/bin/python $LNDG_DIR/controller.py -StandardOutput=append:/var/log/lndg-controller.log -StandardError=append:/var/log/lndg-controller.log +StandardOutput=journal +StandardError=journal Restart=always RestartSec=60s [Install]