Skip to content

Commit

Permalink
Merge pull request #1835 from OriginTrail/v6/prerelease/testnet
Browse files Browse the repository at this point in the history
OriginTrail 6.0.0-beta.1.30 Testnet Release #1832
  • Loading branch information
NZT48 authored Mar 18, 2022
2 parents 99b1ff7 + f19e48f commit ca1ff29
Show file tree
Hide file tree
Showing 15 changed files with 19,626 additions and 144 deletions.
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,5 @@ dist
.tern-port

.DS_Store
package-lock.json

data
2 changes: 1 addition & 1 deletion installer/data/blazegraph.service
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ After=network.target
Type=simple
User=root
WorkingDirectory=/root/
ExecStart=/bin/java -jar /root/blazegraph.jar
ExecStart=/usr/bin/java -jar /root/blazegraph.jar
Restart=on-failure

[Install]
Expand Down
4 changes: 2 additions & 2 deletions installer/data/graphdb.service
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ After=network.target
[Service]
Type=simple
User=root
WorkingDirectory=/root/graphdb-free-9.10.1/bin/
ExecStart=/root/graphdb-free-9.10.1/bin/graphdb
WorkingDirectory=/root/graphdb-free/bin/
ExecStart=/root/graphdb-free/bin/graphdb
Restart=on-failure

[Install]
Expand Down
111 changes: 57 additions & 54 deletions installer/installer.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
#!/bin/bash

OS_VERSION=$(lsb_release -sr)
GRAPHDB_FILE=$(ls /root | grep graphdb-free | grep .zip)
GRAPHDB_FILE=$(ls /root/graphdb*.zip)
GRAPHDB_DIR=$(echo $GRAPHDB_FILE | sed 's|-dist.zip||')
OTNODE_DIR="/root/ot-node"
N1=$'\n'
GREEN='\033[0;32m'
Expand All @@ -14,7 +15,7 @@ cd /root

echo -n "Updating Ubuntu package repository: "

OUTPUT=$(apt update >/dev/null 2>&1)
OUTPUT=$(apt update 2>&1)

if [[ $? -ne 0 ]]; then
echo -e "${RED}FAILED${NC}"
Expand All @@ -27,7 +28,7 @@ fi

echo -n "Updating Ubuntu to latest version (may take a few minutes): "

OUTPUT=$(export DEBIAN_FRONTEND=noninteractive && apt upgrade -y >/dev/null 2>&1)
OUTPUT=$(export DEBIAN_FRONTEND=noninteractive && apt upgrade -y 2>&1)

if [[ $? -ne 0 ]]; then
echo -e "${RED}FAILED${NC}"
Expand All @@ -40,7 +41,7 @@ fi

echo -n "Installing default-jre: "

OUTPUT=$(apt install default-jre unzip jq -y >/dev/null 2>&1)
OUTPUT=$(apt install default-jre unzip jq -y 2>&1)

if [[ $? -ne 0 ]]; then
echo -e "${RED}FAILED${NC}"
Expand Down Expand Up @@ -74,21 +75,33 @@ if [[ $DATABASE = "graphdb" ]]; then
fi

echo -n "Unzipping GraphDB: "
OUTPUT=$(unzip -o $GRAPHDB_FILE >/dev/null 2>&1)
OUTPUT=$(unzip -o $GRAPHDB_FILE >/dev/null 2>&1)
OUTPUT=$(unzip -o $GRAPHDB_FILE 2>&1)

if [[ $? -ne 0 ]]; then
echo -e "${RED}FAILED${NC}"
echo "There was an error unzipping GraphDB."
echo $OUTPUT
exit 1
else
echo -e "${GREEN}SUCCESS${NC}"
fi
if [[ $? -ne 0 ]]; then
echo -e "${RED}FAILED${NC}"
echo "There was an error unzipping GraphDB."
echo $OUTPUT
exit 1
else
echo -e "${GREEN}SUCCESS${NC}"
fi

echo -n "Rename GraphDB directory: "
OUTPUT=$(mv $GRAPHDB_DIR graphdb-free 2>&1)

if [[ $? -ne 0 ]]; then
echo -e "${RED}FAILED${NC}"
echo "There was an error unzipping GraphDB."
echo $OUTPUT
exit 1
else
echo -e "${GREEN}SUCCESS${NC}"
fi

echo -n "Copying graphdb service file: "

OUTPUT=$(cp $OTNODE_DIR/installer/data/graphdb.service /lib/systemd/system/ >/dev/null 2>&1)
OUTPUT=$(cp $OTNODE_DIR/installer/data/graphdb.service /lib/systemd/system/ 2>&1)

if [[ $? -ne 0 ]]; then
echo -e "${RED}FAILED${NC}"
Expand All @@ -103,7 +116,7 @@ if [[ $DATABASE = "graphdb" ]]; then

echo -n "Enable GraphDB service on boot: "

OUTPUT=$(systemctl enable graphdb >/dev/null 2>&1)
OUTPUT=$(systemctl enable graphdb 2>&1)

if [[ $? -ne 0 ]]; then
echo -e "${RED}FAILED${NC}"
Expand All @@ -116,7 +129,7 @@ if [[ $DATABASE = "graphdb" ]]; then

echo -n "Starting GraphDB: "

OUTPUT=$(systemctl start graphdb >/dev/null 2>&1)
OUTPUT=$(systemctl start graphdb 2>&1)

if [[ $? -ne 0 ]]; then
echo -e "${RED}FAILED${NC}"
Expand Down Expand Up @@ -158,7 +171,7 @@ if [[ $DATABASE = "blazegraph" ]]; then

echo -n "Copying blazegraph service file: "

OUTPUT=$(cp $OTNODE_DIR/installer/data/blazegraph.service /lib/systemd/system/ >/dev/null 2>&1)
OUTPUT=$(cp $OTNODE_DIR/installer/data/blazegraph.service /lib/systemd/system/ 2>&1)

if [[ $? -ne 0 ]]; then
echo -e "${RED}FAILED${NC}"
Expand All @@ -173,7 +186,7 @@ if [[ $DATABASE = "blazegraph" ]]; then

echo -n "Enable Blazegraph service on boot: "

OUTPUT=$(systemctl enable blazegraph >/dev/null 2>&1)
OUTPUT=$(systemctl enable blazegraph 2>&1)

if [[ $? -ne 0 ]]; then
echo -e "${RED}FAILED${NC}"
Expand All @@ -186,7 +199,7 @@ if [[ $DATABASE = "blazegraph" ]]; then

echo -n "Starting Blazegraph: "

OUTPUT=$(systemctl start blazegraph >/dev/null 2>&1)
OUTPUT=$(systemctl start blazegraph 2>&1)

if [[ $? -ne 0 ]]; then
echo -e "${RED}FAILED${NC}"
Expand All @@ -211,26 +224,26 @@ if [[ $DATABASE = "blazegraph" ]]; then
fi
fi

echo -n "Downloading Node.js v14: "
echo -n "Downloading Node.js v16: "

OUTPUT=$(wget https://deb.nodesource.com/setup_14.x >/dev/null 2>&1)
OUTPUT=$(wget https://deb.nodesource.com/setup_16.x 2>&1)
if [[ $? -ne 0 ]]; then
echo -e "${RED}FAILED${NC}"
echo "There was an error downloading nodejs setup."
echo "There was an error downloading node.js setup."
echo $OUTPUT
exit 1
else
echo -e "${GREEN}SUCCESS${NC}"
fi

echo -n "Setting up Node.js v14: "
echo -n "Setting up Node.js v16: "

OUTPUT=$(chmod +x setup_14.x)
OUTPUT=$(chmod +x setup_16.x)

OUTPUT=$(./setup_14.x >/dev/null 2>&1)
OUTPUT=$(./setup_16.x 2>&1)
if [[ $? -ne 0 ]]; then
echo -e "${RED}FAILED${NC}"
echo "There was an error setting up nodejs."
echo "There was an error setting up node.js."
echo $OUTPUT
exit 1
else
Expand All @@ -239,7 +252,7 @@ fi

echo -n "Updating the Ubuntu repo: "

OUTPUT=$(apt update >/dev/null 2>&1)
OUTPUT=$(apt update 2>&1)
if [[ $? -ne 0 ]]; then
echo -e "${RED}FAILED${NC}"
echo "There was an error updating the Ubuntu repo."
Expand All @@ -249,24 +262,12 @@ else
echo -e "${GREEN}SUCCESS${NC}"
fi

echo -n "Installing aptitude: "

OUTPUT=$(apt install aptitude -y >/dev/null 2>&1)
if [[ $? -ne 0 ]]; then
echo -e "${RED}FAILED${NC}"
echo "There was an error installing aptitude."
echo $OUTPUT
exit 1
else
echo -e "${GREEN}SUCCESS${NC}"
fi

echo -n "Installing nodejs: "
echo -n "Installing node.js and npm: "

OUTPUT=$(aptitude install nodejs -y >/dev/null 2>&1)
OUTPUT=$(apt-get install node.js -y 2>&1)
if [[ $? -ne 0 ]]; then
echo -e "${RED}FAILED${NC}"
echo "There was an error installing nodejs/npm."
echo "There was an error installing node.js/npm."
echo $OUTPUT
exit 1
else
Expand All @@ -275,7 +276,7 @@ fi

echo -n "Installing tcllib and mysql-server: "

OUTPUT=$(apt install tcllib mysql-server -y >/dev/null 2>&1)
OUTPUT=$(apt-get install tcllib mysql-server -y 2>&1)
if [[ $? -ne 0 ]]; then
echo -e "${RED}FAILED${NC}"
echo "There was an error installing tcllib and mysql-server."
Expand Down Expand Up @@ -315,7 +316,7 @@ fi

echo -n "Commenting out max_binlog_size: "

OUTPUT=$(sed -i 's|max_binlog_size|#max_binlog_size|' /etc/mysql/mysql.conf.d/mysqld.cnf >/dev/null 2>&1)
OUTPUT=$(sed -i 's|max_binlog_size|#max_binlog_size|' /etc/mysql/mysql.conf.d/mysqld.cnf 2>&1)
if [[ $? -ne 0 ]]; then
echo -e "${RED}FAILED${NC}"
echo "There was an error commenting out max_binlog_size."
Expand All @@ -339,7 +340,7 @@ fi

echo -n "Restarting mysql: "

OUTPUT=$(systemctl restart mysql >/dev/null 2>&1)
OUTPUT=$(systemctl restart mysql 2>&1)
if [[ $? -ne 0 ]]; then
echo -e "${RED}FAILED${NC}"
echo "There was an error restarting mysql."
Expand All @@ -354,7 +355,7 @@ cd ot-node

echo -n "Executing npm install: "

OUTPUT=$(npm install >/dev/null 2>&1)
OUTPUT=$(npm install 2>&1)
if [[ $? -ne 0 ]]; then
echo -e "${RED}FAILED${NC}"
echo "There was an error executing npm install."
Expand All @@ -366,7 +367,7 @@ fi

echo -n "Opening firewall ports 22,8900,9000: "

OUTPUT=$(ufw allow 22/tcp && ufw allow 8900 && ufw allow 9000 >/dev/null 2>&1)
OUTPUT=$(ufw allow 22/tcp && ufw allow 8900 && ufw allow 9000 2>&1)
if [[ $? -ne 0 ]]; then
echo -e "${RED}FAILED${NC}"
echo "There was an error opening the firewall ports."
Expand All @@ -378,7 +379,7 @@ fi

echo -n "Enabling the firewall: "

OUTPUT=$(yes | ufw enable >/dev/null 2>&1)
OUTPUT=$(yes | ufw enable 2>&1)
if [[ $? -ne 0 ]]; then
echo -e "${RED}FAILED${NC}"
echo "There was an error enabling the firewall."
Expand Down Expand Up @@ -423,7 +424,7 @@ fi

echo -n "Running DB migrations: "

OUTPUT=$(npx sequelize --config=./config/sequelizeConfig.js db:migrate >/dev/null 2>&1)
OUTPUT=$(npx sequelize --config=./config/sequelizeConfig.js db:migrate 2>&1)
if [[ $? -ne 0 ]]; then
echo -e "${RED}FAILED${NC}"
echo "There was an error running the db migrations."
Expand All @@ -435,7 +436,7 @@ fi

echo -n "Copying otnode service file: "

OUTPUT=$(cp $OTNODE_DIR/installer/data/otnode.service /lib/systemd/system/ >/dev/null 2>&1)
OUTPUT=$(cp $OTNODE_DIR/installer/data/otnode.service /lib/systemd/system/ 2>&1)

if [[ $? -ne 0 ]]; then
echo -e "${RED}FAILED${NC}"
Expand All @@ -450,7 +451,7 @@ systemctl daemon-reload

echo -n "Enable otnode service on boot: "

OUTPUT=$(systemctl enable otnode >/dev/null 2>&1)
OUTPUT=$(systemctl enable otnode 2>&1)

if [[ $? -ne 0 ]]; then
echo -e "${RED}FAILED${NC}"
Expand All @@ -463,7 +464,7 @@ fi

echo -n "Starting otnode: "

OUTPUT=$(systemctl start otnode >/dev/null 2>&1)
OUTPUT=$(systemctl start otnode 2>&1)

if [[ $? -ne 0 ]]; then
echo -e "${RED}FAILED${NC}"
Expand All @@ -488,7 +489,9 @@ else
fi

echo -n "Logs will be displayed. Press ctrl+c to exit the logs. The node WILL stay running after you return to the command prompt."
echo " "
echo ""
echo "If the logs do not show and the screen hangs, press ctrl+c to exit the installation and reboot your server."
echo ""
read -p "Press enter to continue..."

journalctl -u otnode --output cat -fn 100
41 changes: 40 additions & 1 deletion modules/command/common/send-telemetry-command.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
const Command = require('../command');
const constants = require('../../constants');
const Models = require('../../../models/index');
const {v1: uuidv1} = require("uuid");

class SendTelemetryCommand extends Command {
constructor(ctx) {
Expand All @@ -20,14 +21,25 @@ class SendTelemetryCommand extends Command {
return Command.empty();
}

const operationId = uuidv1();

this.telemetryHubModuleManager.aggregateTelemetryData()
.then((jsonld) => {
if (jsonld) {
this.logger.restart();
this.initializeTelemetryPublish(operationId);
Models.handler_ids.create({
status: 'PENDING',
}).then((insertedObject) => {
this.publishService.publish(JSON.stringify(jsonld), '.json', [`ot-telemetry-${Math.floor(new Date() / (60 * 1000))}`], 'public', undefined, insertedObject.dataValues.handler_id, true);
const fileContent = JSON.stringify(jsonld);
const keywords = [`ot-telemetry-${Math.floor(new Date() / (60 * 1000))}`];
this.logger.emit({
msg: 'Finished measuring execution of preparing arguments for publishing',
Event_name: 'publish_prep_args_end',
Operation_name: 'publish_prep_args',
Id_operation: operationId,
});
this.publishService.publish(fileContent, '.json', keywords, 'public', undefined, insertedObject.dataValues.handler_id, operationId, true);
});
}
})
Expand All @@ -38,6 +50,33 @@ class SendTelemetryCommand extends Command {
return Command.repeat();
}

initializeTelemetryPublish(operationId) {
this.logger.emit({
msg: 'Started measuring execution of publish command',
Event_name: 'publish_start',
Operation_name: 'publish',
Id_operation: operationId,
});
this.logger.emit({
msg: 'Started measuring execution of check arguments for publishing',
Event_name: 'publish_init_start',
Operation_name: 'publish_init',
Id_operation: operationId,
});
this.logger.emit({
msg: 'Finished measuring execution of check arguments for publishing',
Event_name: 'publish_init_end',
Operation_name: 'publish_init',
Id_operation: operationId,
});
this.logger.emit({
msg: 'Started measuring execution of preparing arguments for publishing',
Event_name: 'publish_prep_args_start',
Operation_name: 'publish_prep_args',
Id_operation: operationId,
});
}

async recover(command, err) {
await this.handleError(err);

Expand Down
Loading

0 comments on commit ca1ff29

Please sign in to comment.