Move remaining files to parent folder to access settings variables and update docs

This commit is contained in:
cryptosharks131 2021-09-22 23:26:05 -04:00
parent 5d980ccb62
commit ea90b2bcfe
7 changed files with 47 additions and 38 deletions

View file

@ -10,9 +10,9 @@ Lite GUI web interface to analyze lnd data and manage your node with automation.
6. Initialize a settings.py file for your django site `.venv/bin/python initialize.py`
7. Migrate all database objects `.venv/bin/python manage.py migrate`
8. Run the server via chosen webserver or via python development server `.venv/bin/python manage.py runserver <your_node_ip>:80`
9. Generate some initial data for your web GUI `.venv/bin/python gui/jobs.py`
9. Generate some initial data for your web GUI `.venv/bin/python jobs.py`
If you are not using the default path for LND `~/.lnd` you can add a custom path in the django settings file `lndg/settings.py`
Note: If you are not using the default path for LND `~/.lnd` you can add a custom path in the django settings file `lndg/settings.py`
## Updating
1. Make sure you are in the lndg folder `cd lndg`
@ -20,10 +20,15 @@ If you are not using the default path for LND `~/.lnd` you can add a custom path
3. Migrate any database changes `.venv/bin/python manage.py migrate`
## Backend Data Refreshes and Automated Rebalancing
The files `jobs.py` and `rebalancer.py` inside lndg/gui/ serve to update the backend database with the most up to date information and rebalance any channels based on your lndg dashboard settings and requests. A refresh interval of at least 15-30 seconds is recommended for the best user experience.
The files `jobs.py` and `rebalancer.py` inside lndg/gui/ serve to update the backend database with the most up to date information and rebalance any channels based on your lndg dashboard settings and requests. A refresh interval of at least 15-30 seconds is recommended for the best user experience.
You can find instructions on settings these files up to run in the background via systemd [here](https://github.com/cryptosharks131/lndg/blob/master/systemd.md).
You can find instructions on settings these files up to run in the background via systemd [here](https://github.com/cryptosharks131/lndg/blob/master/systemd.md).
If you are familiar with crontab, this is also an option for setting up these files to run on a frequent basis, however it only has a resolution of 1 minute.
A bash script has also been included to install the systemd setup. `sudo bash systemd.sh`
## Nginx Webserver
If you would like to serve the dashboard at all times, it is recommended to setup a proper production webserver to host the site.
A bash script has been included to help aide in the setup of a nginx webserver. `sudo bash nginx.sh`
## API Backend
The following data can be accessed at the /api endpoint: `payments`, `invoices`, `forwards`, `channels`, and `rebalancer`

View file

@ -1,17 +1,18 @@
import os, codecs, grpc
from lnd_deps import lightning_pb2 as ln
from lnd_deps import lightning_pb2_grpc as lnrpc
from lndg import settings
from gui.lnd_deps import lightning_pb2 as ln
from gui.lnd_deps import lightning_pb2_grpc as lnrpc
#Define lnd connection for repeated use
def lnd_connect():
#Open connection with lnd via grpc
with open(os.path.expanduser('~/.lnd/data/chain/bitcoin/mainnet/admin.macaroon'), 'rb') as f:
with open(os.path.expanduser(settings.LND_DIR_PATH + '/data/chain/bitcoin/mainnet/admin.macaroon'), 'rb') as f:
macaroon_bytes = f.read()
macaroon = codecs.encode(macaroon_bytes, 'hex')
def metadata_callback(context, callback):
callback([('macaroon', macaroon)], None)
os.environ["GRPC_SSL_CIPHER_SUITES"] = 'HIGH+ECDSA'
cert = open(os.path.expanduser('~/.lnd/tls.cert'), 'rb').read()
cert = open(os.path.expanduser(settings.LND_DIR_PATH + '/tls.cert'), 'rb').read()
cert_creds = grpc.ssl_channel_credentials(cert)
auth_creds = grpc.metadata_call_credentials(metadata_callback)
creds = grpc.composite_channel_credentials(cert_creds, auth_creds)

View file

@ -3,10 +3,10 @@ from django.conf import settings
from django.db.models import Max
from pathlib import Path
from datetime import datetime
from lnd_deps import lightning_pb2 as ln
from lnd_deps import lightning_pb2_grpc as lnrpc
from gui.lnd_deps import lightning_pb2 as ln
from gui.lnd_deps import lightning_pb2_grpc as lnrpc
BASE_DIR = Path(__file__).resolve().parent.parent
BASE_DIR = Path(__file__).resolve().parent
settings.configure(
DATABASES = {
'default': {
@ -16,7 +16,8 @@ settings.configure(
}
)
django.setup()
from models import Payments, PaymentHops, Invoices, Forwards, Channels, Peers
from lndg import settings
from gui.models import Payments, PaymentHops, Invoices, Forwards, Channels, Peers
def update_payments(stub):
#Remove anything in-flight so we can get most up to date status
@ -192,13 +193,13 @@ def reconnect_peers(stub):
def lnd_connect():
#Open connection with lnd via grpc
with open(os.path.expanduser('~/.lnd/data/chain/bitcoin/mainnet/admin.macaroon'), 'rb') as f:
with open(os.path.expanduser(settings.LND_DIR_PATH + '/data/chain/bitcoin/mainnet/admin.macaroon'), 'rb') as f:
macaroon_bytes = f.read()
macaroon = codecs.encode(macaroon_bytes, 'hex')
def metadata_callback(context, callback):
callback([('macaroon', macaroon)], None)
os.environ["GRPC_SSL_CIPHER_SUITES"] = 'HIGH+ECDSA'
cert = open(os.path.expanduser('~/.lnd/tls.cert'), 'rb').read()
cert = open(os.path.expanduser(settings.LND_DIR_PATH + '/tls.cert'), 'rb').read()
cert_creds = grpc.ssl_channel_credentials(cert)
auth_creds = grpc.metadata_call_credentials(metadata_callback)
creds = grpc.composite_channel_credentials(cert_creds, auth_creds)

View file

@ -1,17 +1,18 @@
import os, codecs, grpc, secrets
from hashlib import sha256
from lnd_deps import router_pb2 as lnr
from lnd_deps import router_pb2_grpc as lnrouter
from lndg import settings
from gui.lnd_deps import router_pb2 as lnr
from gui.lnd_deps import router_pb2_grpc as lnrouter
def lnd_connect():
#Open connection with lnd via grpc
with open(os.path.expanduser('~/.lnd/data/chain/bitcoin/mainnet/admin.macaroon'), 'rb') as f:
with open(os.path.expanduser(settings.LND_DIR_PATH + '/data/chain/bitcoin/mainnet/admin.macaroon'), 'rb') as f:
macaroon_bytes = f.read()
macaroon = codecs.encode(macaroon_bytes, 'hex')
def metadata_callback(context, callback):
callback([('macaroon', macaroon)], None)
os.environ["GRPC_SSL_CIPHER_SUITES"] = 'HIGH+ECDSA'
cert = open(os.path.expanduser('~/.lnd/tls.cert'), 'rb').read()
cert = open(os.path.expanduser(settings.LND_DIR_PATH + '/tls.cert'), 'rb').read()
cert_creds = grpc.ssl_channel_credentials(cert)
auth_creds = grpc.metadata_call_credentials(metadata_callback)
creds = grpc.composite_channel_credentials(cert_creds, auth_creds)

View file

@ -3,12 +3,12 @@ from django.conf import settings
from django.db.models import Sum
from pathlib import Path
from datetime import datetime
from lnd_deps import lightning_pb2 as ln
from lnd_deps import lightning_pb2_grpc as lnrpc
from lnd_deps import router_pb2 as lnr
from lnd_deps import router_pb2_grpc as lnrouter
from gui.lnd_deps import lightning_pb2 as ln
from gui.lnd_deps import lightning_pb2_grpc as lnrpc
from gui.lnd_deps import router_pb2 as lnr
from gui.lnd_deps import router_pb2_grpc as lnrouter
BASE_DIR = Path(__file__).resolve().parent.parent
BASE_DIR = Path(__file__).resolve().parent
settings.configure(
DATABASES = {
'default': {
@ -18,18 +18,19 @@ settings.configure(
}
)
django.setup()
from models import Rebalancer, Channels, LocalSettings
from lndg import settings
from gui.models import Rebalancer, Channels, LocalSettings
#Define lnd connection for repeated use
def lnd_connect():
#Open connection with lnd via grpc
with open(os.path.expanduser('~/.lnd/data/chain/bitcoin/mainnet/admin.macaroon'), 'rb') as f:
with open(os.path.expanduser(settings.LND_DIR_PATH + '/data/chain/bitcoin/mainnet/admin.macaroon'), 'rb') as f:
macaroon_bytes = f.read()
macaroon = codecs.encode(macaroon_bytes, 'hex')
def metadata_callback(context, callback):
callback([('macaroon', macaroon)], None)
os.environ["GRPC_SSL_CIPHER_SUITES"] = 'HIGH+ECDSA'
cert = open(os.path.expanduser('~/.lnd/tls.cert'), 'rb').read()
cert = open(os.path.expanduser(settings.LND_DIR_PATH + '/tls.cert'), 'rb').read()
cert_creds = grpc.ssl_channel_credentials(cert)
auth_creds = grpc.metadata_call_credentials(metadata_callback)
creds = grpc.composite_channel_credentials(cert_creds, auth_creds)

View file

@ -4,11 +4,11 @@ You will need to fill in the proper username below in the paths marked `<run_as_
## Backend Refreshes
Create a simple bash file to call `jobs.py`, copying the contents below to the file.
`nano /home/<run_as_user>/lndg/gui/jobs.sh`
`nano /home/<run_as_user>/lndg/jobs.sh`
```
#!/bin/bash
/home/<run_as_user>/lndg/.venv/bin/python /home/<run_as_user>/lndg/gui/jobs.py
/home/<run_as_user>/lndg/.venv/bin/python /home/<run_as_user>/lndg/jobs.py
```
Create a service file for `jobs.py`, copying the contents below to the file and filling in the user you would like this to run under.
`nano /etc/systemd/system/jobs-lndg.service`
@ -18,7 +18,7 @@ Description=Run Jobs For Lndg
[Service]
User=<run_as_user>
Group=<run_as_user>
ExecStart=/usr/bin/bash /home/<run_as_user>/lndg/gui/jobs.sh
ExecStart=/usr/bin/bash /home/<run_as_user>/lndg/jobs.sh
StandardError=append:/var/log/lnd_jobs_error.log
```
@ -40,11 +40,11 @@ Enable the timer to run the jobs service file at the specified interval.
## Rebalancer Runs
Create a simple bash file to call `rebalancer.py`, copying the contents below to the file.
`nano /home/<run_as_user>/lndg/gui/rebalancer.sh`
`nano /home/<run_as_user>/lndg/rebalancer.sh`
```
#!/bin/bash
/home/<run_as_user>/lndg/.venv/bin/python /home/<run_as_user>/lndg/gui/rebalancer.py
/home/<run_as_user>/lndg/.venv/bin/python /home/<run_as_user>/lndg/rebalancer.py
```
Create a service file for `rebalancer.py`, copying the contents below to the file and filling in the user you would like this to run under.
`nano /etc/systemd/system/rebalancer-lndg.service`
@ -54,7 +54,7 @@ Description=Run Rebalancer For Lndg
[Service]
User=<run_as_user>
Group=<run_as_user>
ExecStart=/usr/bin/bash /home/<run_as_user>/lndg/gui/rebalancer.sh
ExecStart=/usr/bin/bash /home/<run_as_user>/lndg/rebalancer.sh
StandardError=append:/var/log/lnd_rebalancer_error.log
RuntimeMaxSec=3600
```

View file

@ -4,10 +4,10 @@ RED='\033[0;31m'
NC='\033[0m'
function configure_jobs() {
cat << EOF > /home/$INSTALL_USER/lndg/gui/jobs.sh
cat << EOF > /home/$INSTALL_USER/lndg/jobs.sh
#!/bin/bash
/home/$INSTALL_USER/lndg/.venv/bin/python /home/$INSTALL_USER/lndg/gui/jobs.py
/home/$INSTALL_USER/lndg/.venv/bin/python /home/$INSTALL_USER/lndg/jobs.py
EOF
cat << EOF > /etc/systemd/system/jobs-lndg.service
@ -16,7 +16,7 @@ Description=Run Jobs For Lndg
[Service]
User=$INSTALL_USER
Group=$INSTALL_USER
ExecStart=/usr/bin/bash /home/$INSTALL_USER/lndg/gui/jobs.sh
ExecStart=/usr/bin/bash /home/$INSTALL_USER/lndg/jobs.sh
StandardError=append:/var/log/lnd_jobs_error.log
EOF
@ -33,10 +33,10 @@ EOF
}
function configure_rebalancer() {
cat << EOF > /home/$INSTALL_USER/lndg/gui/rebalancer.sh
cat << EOF > /home/$INSTALL_USER/lndg/rebalancer.sh
#!/bin/bash
/home/$INSTALL_USER/lndg/.venv/bin/python /home/$INSTALL_USER/lndg/gui/jobs.py
/home/$INSTALL_USER/lndg/.venv/bin/python /home/$INSTALL_USER/lndg/jobs.py
EOF
cat << EOF > /etc/systemd/system/rebalancer-lndg.service
@ -45,7 +45,7 @@ Description=Run Rebalancer For Lndg
[Service]
User=$INSTALL_USER
Group=$INSTALL_USER
ExecStart=/usr/bin/bash /home/$INSTALL_USER/lndg/gui/rebalancer.sh
ExecStart=/usr/bin/bash /home/$INSTALL_USER/lndg/rebalancer.sh
StandardError=append:/var/log/lnd_rebalancer_error.log
RuntimeMaxSec=3600
EOF