Standard
Prerequisites
- Go 1.22 (opens in a new tab)
- Node 18 (opens in a new tab)
- Git (opens in a new tab) (
git
might be pre-installed) - PM2 (opens in a new tab)
npm install -g pm2
oryarn global add pm2
- jq (opens in a new tab)
sudo apt-get install jq
- Compatible Database - See Database Setup
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.
-
Clone repo
git clone https://github.com/UnownHash/Dragonite-Public.git Dragonite
-
Change into cloned repo
cd Dragonite
-
Download latest release binaries
./run.sh
-
Create your
config.toml
files from the two included example filescp admin/config.toml.example admin/config.toml cp dragonite/config.toml.example dragonite/config.toml
-
Modify your
dragonite/config.toml
file. Minimum requirement:-
db.dragonite
settings -
golbat_*
settings
Additionally, we highly recommend setting a the
raw_bearer
,api_secret
andbearer_token
keys if this service is accessible from the public internet. -
-
Modify your
admin/config.toml
file. The defaults will work out of box but are not secure. -
To run the service
cd admin && ./admin-linux-amd64 cd dragonite && ./dragonite-linux-amd64
Install Golbat
-
Clone repo
git clone https://github.com/UnownHash/Golbat.git
-
Change into cloned repo
cd Golbat
-
Create
config.toml
from example filecp config.toml.example config.toml
-
Modify your config file. Minimum requirement:
- database settings
-
Build and run the service
go run .
To compile a static binary run
make
Install Rotom
-
Clone repo
git clone https://github.com/UnownHash/Rotom.git
-
Change into cloned repo
cd Rotom
-
Create configuration file
cp config/local.json.example config/local.json
-
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 to0.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.
- The
-
Install the dependencies
npm ci
-
Build the application
npm run build
-
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
-
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
-
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).
-
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
-
Create your config file
Make sure to update your
cmd
paths and optionally modify themax_memory_restart
setting.ecosystem.config.jsmodule.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' }, ] }
-
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
-
Change into Dragonite directory
cd path/to/Dragonite
-
Pull latest binaries
git pull ./run.sh
-
Restart services
pm2 restart dragonite dragonite-admin
Golbat
-
Change into Golbat directory
cd path/to/Golbat
-
Pull latest git changes and compile
git pull && make
-
Restart service
pm2 restart golbat
Rotom
-
Change into Rotom directory
cd path/to/Rotom
-
Pull latest git changes and compile
git pull && npm ci && npm run build
-
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.
-
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"
-
Make the script executable
chmod +x update-unownhash.sh
-
Run the script
./update-unownhash.sh