mirror of
https://github.com/lalanza808/monero.fail.git
synced 2025-03-14 07:36:29 -04:00
update docs, remove bin, fix ux on no data
This commit is contained in:
parent
615665a943
commit
3bef35dd32
1
.gitignore
vendored
1
.gitignore
vendored
@ -129,5 +129,4 @@ dmypy.json
|
||||
.pyre/
|
||||
|
||||
# nodes
|
||||
config.py
|
||||
data
|
||||
|
11
Makefile
11
Makefile
@ -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
|
19
README.md
19
README.md
@ -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`.
|
||||
|
7
bin/cmd
7
bin/cmd
@ -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
|
7
bin/dev
7
bin/dev
@ -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
|
21
bin/prod
21
bin/prod
@ -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)"
|
7
env-example
Normal file
7
env-example
Normal file
@ -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
|
31
manage.sh
Executable file
31
manage.sh
Executable file
@ -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
|
||||
)
|
||||
|
||||
|
14
xmrnodes/config.py
Normal file
14
xmrnodes/config.py
Normal file
@ -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…
x
Reference in New Issue
Block a user