Giter VIP home page Giter VIP logo

dpow-mqtt's Introduction

Nano Distributed POW Dashboard

The purpose of this dashboard is to show the health of the distributed proof of work network and provide some key performance indicators for reference. The dashboard runs on a flask server which requires configuration through a reverse proxy and connects to the DPoW Network using MQTT.

Setup

Requirements for this setup:

sudo apt update

sudo apt install python3-pip python3-dev build-essential libssl-dev libffi-dev python3-setuptools python3-venv nginx redis-server mysql-server libmysqlclient-dev

It's recommended to use a virtual environment to handle the python requirements.

Steps:

  1. Activate the redis server: sudo systemctl enable redis-server.service
  2. Navigate to the dpow-mqtt directory
  3. Activate your virtual environment: virtualenv -p python3 venv
  4. source venv/bin/activate
  5. run: pip install -r requirements.txt
  6. Copy the example services to the systemd directory:
    sudo cp exampleflaskservice.service /etc/systemd/system/dpowdash.service
    sudo cp exampleservice.service /etc/systemd/system/dpowmqtt.service
  7. Update services with proper information:
    sudo vim /etc/systemd/system/dpowdash.service
    sudo vim /etc/systemd/system/dpowmqtt.service
  8. Copy the exampleconfig.ini: cp exampleconfig.ini config.ini
  9. Update the config.ini with appropriate values: sudo vim config.ini
  10. Ensure dpow.py is executable: sudo chmod -x mqtt.py
  11. Modify the shebang at the top of mqtt.py to the correct path. Example: /home/{YOUR_USER}/dpow-mqtt/venv/bin/python3
  12. sudo systemctl start dpowdash sudo systemctl start dpowmqtt - start the dashboard & mqtt client
  13. sudo systemctl enable dpowdash sudo systemctl enable dpowmqtt - start the services on boot

After the service is running, you must configure Nginx to proxy requests

  1. sudo vim /etc/nginx/sites-available/dpowdash
  2. Update the file as below:
server {
    listen 80;
    server_name {YOUR_DOMAIN} www.{YOUR_DOMAIN};

    location / {
        include proxy_params;
        proxy_pass http://unix:/home/{YOUR_USER}/dpow-mqtt/dpowdash.sock;
    }
}

  3. Create a link to the enabled sites directory: sudo ln -s /etc/nginx/sites-available/dpowdash /etc/nginx/sites-enabled
  4. Test for syntax errors: sudo nginx -t
  5. If no errors: sudo systemctl restart nginx
  6. Ensure that Nginx is allowed: sudo ufw allow 'Nginx Full'

The final step is to set up cron jobs to run the log updates every 24 hours and update the cache every minute. This gives the client_log and service_log their information to generate the change over 24 hours.

  1. Ensure the log_update.sh file is executable: sudo chmod +x log_update.sh
  2. Run sudo crontab -e and select whatever editor you're comfortable with.
  3. Insert the following line at the end of the file: 0 2 * * * {YOUR_USERNAME} /path/to/dpow-mqtt/log_update.sh
  4. Insert the following line at the end of the file: * * * * * {YOUR_USERNAME} cd /path/to/dpow-mqtt && /path/to/dpow-mqtt/venv/bin/python3.7 /path/to/dpow-mqtt/cache.py >> /var/log/dpow-mqtt/cron.log 2>&1
  5. Update log_update.sh to direct to the correct path of config.ini: /path/to/dpow-mqtt/config.ini

You should now be able to navigate to http://{YOUR_DOMAIN} to access the dashboard. HTTPS is recommended, but not required. For more information, google Certbot to easily generate a certificate and enable HTTPS.

Troubleshooting

If you notice that you're not able to reach via your registered domain, check permissions for the folders.
Standards suggest to set the owner and group to root:www-data so nginx has access.

dpow-mqtt's People

Contributors

keerifox avatar mitche50 avatar

Watchers

 avatar  avatar

Forkers

bbedward

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.