Documentation
Getting Started
Standard

Standard

Prerequisites

Install Dragonite

ℹ️

This setup guide is written for Linux. All referenced Dragonite binary files will have the -linux-amd64 suffix. Using a different platform like macOS (darwin) will change the suffix. Windows builds are currently not available and we recommend Windows users use Windows Subsystem for Linux (WSL) or docker.

  1. Clone repo

    git clone https://github.com/UnownHash/Dragonite-Public.git Dragonite
  2. Change into cloned repo

    cd Dragonite
  3. Download latest release binaries

    ./run.sh
  4. Create your config.toml files from the two included example files

    cp admin/config.toml.example admin/config.toml
    cp dragonite/config.toml.example dragonite/config.toml
  5. Modify your dragonite/config.toml file. Minimum requirement:

    • db.dragonite settings

    • golbat_* settings

    Additionally, we highly recommend setting a the raw_bearer, api_secret and bearer_token keys if this service is accessible from the public internet.

  6. Modify your admin/config.toml file. The defaults will work out of box but are not secure.

  7. To run the service

    cd admin && ./admin-linux-amd64
    cd dragonite && ./dragonite-linux-amd64

Install Golbat

  1. Clone repo

    git clone https://github.com/UnownHash/Golbat.git
  2. Change into cloned repo

    cd Golbat
  3. Create config.toml from example file

    cp config.toml.example config.toml
  4. Modify your config file. Minimum requirement:

    • database settings
  5. Build and run the service

    go run .
ℹ️

To compile a static binary run

make

Install Rotom

  1. Clone repo

    git clone https://github.com/UnownHash/Rotom.git
  2. Change into cloned repo

    cd Rotom
  3. Create configuration file

    cp config/local.json.example config/local.json
  4. Modify your configuration file at config/local.json

    Please note Rotom does not have any authentication for it's web client. It is recommended that you run this service on your internal network, behind a Firewall, or protected by a cloud based application layer.

    • The client.port might need to be updated to 0.0.0.0 depending on how you run your server.
    • You can also modify the monitoring values however it is unclear if they are actually used by any MITM tools at this time.
  5. Install the dependencies

    npm ci
  6. Build the application

    npm run build
  7. To run the service

    npm run start

    By default you should be able to access the frontend via http://serverIP:7072

PM2

All services are now setup but navigating to each folder and starting each service one at a time is not ideal. Instead we will use pm2 which will maintain the lifecycle of the service, restarting, and optionally starting it on server reboot (pm2 startup).

Standard Setup

  1. Navigate to each service folder and compile a static binary

    cd /path/to/Dragonite/ && ./run.sh
    cd /path/to/Golbat && go build golbat
    cd /path/to/Rotom/ && npm ci && npm run build
  2. Run the following to start and save a service

     # Dragonite
     pm2 start ./dragonite-linux-amd64 --name "dragonite" -o "/dev/null"
     pm2 start ./admin-linux-amd64 --name "dragonite-admin" -o "/dev/null"
     # Golbat
     pm2 start ./golbat --name "golbat" -o "/dev/null"
     # Rotom
     pm2 start dist/packages/server/main.js --name "rotom"
     
     pm2 save

Ecosystem File

Instead of creating each service individually we can use an PM2 - Ecosystem File (opens in a new tab).

  1. Navigate to each folder and compile a static binary

    cd /path/to/Dragonite/ && ./run.sh
    cd /path/to/Golbat && go build golbat
    cd /path/to/Rotom/ && npm ci && npm run build
  2. Create your config file

    Make sure to update your cmd paths and optionally modify the max_memory_restart setting.

    ecosystem.config.js
    module.exports = {
      apps : [
        {
            name: 'dragonite',
            script: 'dragonite-linux-amd64',
            cwd: '/home/username/Dragonite/dragonite',
            instances: 1,
            autorestart: true,
            log_date_format: "YYYY-MM-DD HH:mm",
            max_memory_restart: '4G'
        },
        {
            name: 'dragonite-admin',
            script: 'admin-linux-amd64',
            cwd: '/home/username/Dragonite/admin',
            instances: 1,
            autorestart: true,
            log_date_format: "YYYY-MM-DD HH:mm",
            max_memory_restart: '1G'
        },
        {
            name: 'golbat',
            script: 'golbat',
            cwd: '/home/username/Golbat/',
            instances: 1,
            autorestart: true,
            log_date_format: "YYYY-MM-DD HH:mm",
            max_memory_restart: '4G'
        },
        {
            name: 'rotom',
            script: 'dist/packages/server/main.js',
            cwd: '/home/username/Rotom/',
            instances: 1,
            autorestart: true,
            log_date_format: "YYYY-MM-DD HH:mm",
            max_memory_restart: '4G'
        },
      ]
    }
  3. Start and save the services

    pm2 start ecosystem.config.js
    pm2 save

PM2 logs

Overtime pm2 logs can take up large amounts of disk space. There is a popular pm2 module called pm2-logrotate that handles this log rotation for you. While it is optional we do recommend it.

Basic setup below:

pm2 install pm2-logrotate
pm2 set pm2-logrotate:max_size 50M
pm2 set pm2-logrotate:retain 10
pm2 set pm2-logrotate:compress true

Updating

Since each service is an individual component it is possible to update just one. IE - no need to stop our data parser (Golbat) because the backend controller (Dragonite) has an update.

Dragonite

  1. Change into Dragonite directory

    cd path/to/Dragonite
  2. Pull latest binaries

    git pull
    ./run.sh
  3. Restart services

    pm2 restart dragonite dragonite-admin

Golbat

  1. Change into Golbat directory

    cd path/to/Golbat
  2. Pull latest git changes and compile

    git pull && make
  3. Restart service

    pm2 restart golbat

Rotom

  1. Change into Rotom directory

    cd path/to/Rotom
  2. Pull latest git changes and compile

    git pull && npm ci && npm run build
  3. Restart service

    pm2 restart rotom

All projects

If you wish to update all components and do not want to worry about forgetting a step you can use the following script. This will update all services at once.

Make sure to update the hightlighted path variable on line 2.

  1. Copy the below script

    update-unownhash.sh
    #!/usr/bin/env bash
    START_DIR=/home/username
     
    echo "Updating Golbat"
    cd "$START_DIR"/Golbat
    git pull
    go build golbat
     
    echo "Updating Dragonite"
    pm2 stop dragonite dragonite-admin
    cd "$START_DIR"/Dragonite
    ./run.sh
     
    echo "Updating Rotom"
    cd "$START_DIR"/Rotom
    npm ci
    npm run build
     
    cd ~
    pm2 restart golbat dragonite dragonite-admin rotom
     
    echo "All services have been updated"
  2. Make the script executable

    chmod +x update-unownhash.sh
  3. Run the script

    ./update-unownhash.sh