update docs, remove bin, fix ux on no data

pull/26/head
lza_menace 2 years ago
parent 615665a943
commit 3bef35dd32

1
.gitignore vendored

@ -129,5 +129,4 @@ dmypy.json
.pyre/
# nodes
config.py
data

@ -1,17 +1,20 @@
setup:
python3 -m venv .venv
.venv/bin/pip install -r requirements.txt
mkdir data
wget https://github.com/P3TERX/GeoLite.mmdb/raw/download/GeoLite2-City.mmdb -P data
mkdir -p data
wget https://github.com/P3TERX/GeoLite.mmdb/raw/download/GeoLite2-City.mmdb -P data --no-clobber
up:
docker-compose up -d
dev:
./bin/dev
./manage.sh run
prod:
./bin/prod
./manage.sh prod
logs:
docker-compose logs -f
kill:
pkill -ef xmrnodes

@ -20,9 +20,10 @@ The map portion of the service requires the GeoLite2 db...the `make setup` comma
# install python virtual environment and install application dependencies
make setup
# setup config
cp xmrnodes/config.example.py xmrnodes/config.py
vim xmrnodes/config.py
# default configs work out of the box, modify .env if needed
# setup .env
cp env-example .env
vim .env
# run services (tor, i2p, etc)
make up
@ -32,3 +33,15 @@ make dev
# access at http://127.0.0.1:5000
```
### Production
For production, update `SERVER_NAME` in `.env` to your production URL/domain. Use `manage.sh` (or provided `Makefile`) to serve the Flask process using Gunicorn.
```
./manage.sh prod
```
Runs the Gunicorn process on port 4000. Setup a web server to proxy requests to that port.
Kill production Gunicorn with `make kill`.

@ -1,7 +0,0 @@
#!/bin/bash
source .venv/bin/activate
export FLASK_APP=xmrnodes/app.py
export FLASK_SECRETS=config.py
export FLASK_DEBUG=1
flask $1

@ -1,7 +0,0 @@
#!/bin/bash
source .venv/bin/activate
export FLASK_APP=xmrnodes/app.py
export FLASK_SECRETS=config.py
export FLASK_DEBUG=1
flask run

@ -1,21 +0,0 @@
#!/bin/bash
BASE=data/gunicorn
source .venv/bin/activate
export FLASK_APP=xmrnodes/app.py
export FLASK_SECRETS=config.py
export FLASK_DEBUG=0
export FLASK_ENV=production
mkdir -p $BASE
gunicorn \
--bind 127.0.0.1:4000 "xmrnodes.app:app" \
--daemon \
--log-file $BASE/gunicorn.log \
--pid $BASE/gunicorn.pid \
--access-logfile $BASE/access.log \
--reload
echo "Starting gunicorn with pid $(cat $BASE/gunicorn.pid)"

@ -0,0 +1,7 @@
SECRET_KEY=randomstringyoumakeup
SERVER_NAME=127.0.0.1:5000
DATA_DIR=./data
TOR_HOST=127.0.0.1
TOR_PORT=9050
NODE_HOST=singapore.node.xmr.pm
NODE_PORT=18080

@ -0,0 +1,31 @@
#!/bin/bash
source .venv/bin/activate
export FLASK_APP=xmrnodes/app.py
export FLASK_SECRETS=config.py
export FLASK_DEBUG=1
export FLASK_ENV=development
# override
source .env
if [[ ${1} == "prod" ]];
then
export FLASK_DEBUG=0
export FLASK_ENV=production
export BASE=./data/gunicorn
mkdir -p $BASE
pgrep -F $BASE/gunicorn.pid
if [[ $? != 0 ]]; then
gunicorn \
--bind 127.0.0.1:4000 "xmrnodes.app:app" \
--daemon \
--log-file $BASE/gunicorn.log \
--pid $BASE/gunicorn.pid \
--reload
sleep 2
echo "Started gunicorn on 127.0.0.1:4000 with pid $(cat $BASE/gunicorn.pid)"
fi
else
flask $@
fi

@ -7,3 +7,4 @@ flask_wtf
pysocks
git+https://github.com/cdiv1e12/py-levin
geoip2
python-dotenv

@ -164,9 +164,14 @@ def wow_nodes_json():
@app.route("/map")
def map():
try:
peers = rw_cache('map_peers')
except:
flash('Couldn\'t load the map. Try again later.')
return redirect('/')
return render_template(
"map.html",
peers=rw_cache('map_peers'),
peers=peers,
source_node=config.NODE_HOST
)

@ -0,0 +1,14 @@
import os
from secrets import token_urlsafe
from dotenv import load_dotenv
load_dotenv()
SECRET_KEY = os.environ.get('SECRET_KEY', token_urlsafe(14))
SERVER_NAME = os.environ.get('SERVER_NAME', '127.0.0.1:5000')
DATA_DIR = os.environ.get('DATA_DIR', './data')
TOR_HOST = os.environ.get('TOR_HOST', '127.0.0.1')
TOR_PORT = os.environ.get('TOR_PORT', 9050)
NODE_HOST = os.environ.get('NODE_HOST', 'singapore.node.xmr.pm')
NODE_PORT = os.environ.get('NODE_PORT', 18080)
Loading…
Cancel
Save