Skip to content

Commit

Permalink
Merge pull request #2087 from OriginTrail/v6/hot-fix/release/testnet
Browse files Browse the repository at this point in the history
OriginTrail 6.0.0-beta.2.2.4 Testnet Release
  • Loading branch information
NZT48 authored Sep 9, 2022
2 parents e80cdc7 + 4326471 commit 0391a72
Show file tree
Hide file tree
Showing 169 changed files with 40,284 additions and 21,515 deletions.
2 changes: 1 addition & 1 deletion .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/sh
. "$(dirname "$0")/_/husky.sh"

npm run lint-staged
#npm run lint-staged
2 changes: 1 addition & 1 deletion Alpine.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ RUN tar xzf ./remote_syslog_linux_amd64.tar.gz && cd remote_syslog && cp ./remot

COPY config/papertrail.yml /etc/log_files.yml

#Install git & forever
#Install nodemon, git & forever
RUN npm install forever -g
RUN apk add git

Expand Down
4 changes: 2 additions & 2 deletions Debian.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ COPY config/papertrail.yml /etc/log_files.yml



#Install forever
#Install nodemon & forever
RUN npm install forever -g


Expand All @@ -52,5 +52,5 @@ COPY . .
RUN npm install

#Mysql intialization
RUN service mariadb start && mysql -u root -e "CREATE DATABASE operationaldb /*\!40100 DEFAULT CHARACTER SET utf8 */; SET PASSWORD FOR root@localhost = PASSWORD(''); FLUSH PRIVILEGES;"
RUN service mariadb start && mysql -u root -e "CREATE DATABASE operationaldb /*\!40100 DEFAULT CHARACTER SET utf8 */; SET PASSWORD FOR root@localhost = PASSWORD(''); FLUSH PRIVILEGES;" && npx sequelize --config=./config/sequelizeConfig.js db:migrate

4 changes: 2 additions & 2 deletions Ubuntu.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ COPY config/papertrail.yml /etc/log_files.yml



#Install forever
#Install nodemon
RUN npm install -g forever


Expand All @@ -38,5 +38,5 @@ RUN npm install
#Intialize mysql
RUN usermod -d /var/lib/mysql/ mysql
RUN echo "disable_log_bin" >> /etc/mysql/mysql.conf.d/mysqld.cnf
RUN service mysql start && mysql -u root -e "CREATE DATABASE operationaldb /*\!40100 DEFAULT CHARACTER SET utf8 */; update mysql.user set plugin = 'mysql_native_password' where User='root'/*\!40100 DEFAULT CHARACTER SET utf8 */; flush privileges;"
RUN service mysql start && mysql -u root -e "CREATE DATABASE operationaldb /*\!40100 DEFAULT CHARACTER SET utf8 */; update mysql.user set plugin = 'mysql_native_password' where User='root'/*\!40100 DEFAULT CHARACTER SET utf8 */; flush privileges;" && npx sequelize --config=./config/sequelizeConfig.js db:migrate

131 changes: 39 additions & 92 deletions config/config.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docker/docker-compose-alpine-blazegraph.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ services:
command:
- '/bin/sh'
- '-c'
- '/bin/sleep 25 && forever index.js'
- '/bin/sleep 25 && npx sequelize --config=./config/sequelizeConfig.js db:migrate && forever index.js'


volumes:
Expand Down
2 changes: 1 addition & 1 deletion docker/docker-compose-alpine-graphdb.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ services:
command:
- '/bin/sh'
- '-c'
- '/bin/sleep 25 && forever index.js'
- '/bin/sleep 25 && npx sequelize --config=./config/sequelizeConfig.js db:migrate && forever index.js'


volumes:
Expand Down
14 changes: 7 additions & 7 deletions index.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
/* eslint-disable no-console */
import 'dotenv/config';
import fs from 'fs-extra';
import path from 'path';
import appRootPath from 'app-root-path';
import { execSync } from 'child_process';
import semver from 'semver';
import OTNode from './ot-node.js';
require('dotenv').config();
const fs = require('fs-extra');
const path = require('path');
const appRootPath = require('app-root-path');
const { execSync } = require('child_process');
const semver = require('semver');
const OTNode = require('./ot-node');

process.env.NODE_ENV =
process.env.NODE_ENV && ['development', 'testnet', 'mainnet'].indexOf(process.env.NODE_ENV) >= 0
Expand Down
55 changes: 37 additions & 18 deletions ot-node.js
Original file line number Diff line number Diff line change
@@ -1,18 +1,16 @@
import DeepExtend from 'deep-extend';
import rc from 'rc';
import fs from 'fs';
import appRootPath from 'app-root-path';
import path from 'path';
import EventEmitter from 'events';
import { createRequire } from 'module';
import DependencyInjection from './src/service/dependency-injection.js';
import Logger from './src/logger/logger.js';
import { MIN_NODE_VERSION } from './src/constants/constants.js';
import FileService from './src/service/file-service.js';

const require = createRequire(import.meta.url);
const DeepExtend = require('deep-extend');
const rc = require('rc');
const fs = require('fs');
const queue = require('fastq');
const appRootPath = require('app-root-path');
const path = require('path');
const EventEmitter = require('events');
const DependencyInjection = require('./src/service/dependency-injection');
const Logger = require('./src/logger/logger');
const constants = require('./src/constants/constants');
const pjson = require('./package.json');
const configjson = require('./config/config.json');
const FileService = require('./src/service/file-service');

class OTNode {
constructor(config) {
Expand All @@ -36,7 +34,7 @@ class OTNode {
this.logger.info('======================================================');
this.logger.info(`Node is running in ${process.env.NODE_ENV} environment`);

await this.initializeDependencyContainer();
this.initializeDependencyContainer();
this.initializeEventEmitter();

await this.initializeModules();
Expand All @@ -54,7 +52,7 @@ class OTNode {
const nodeMajorVersion = process.versions.node.split('.')[0];
this.logger.warn('======================================================');
this.logger.warn(`Using node.js version: ${process.versions.node}`);
if (nodeMajorVersion < MIN_NODE_VERSION) {
if (nodeMajorVersion < constants.MIN_NODE_VERSION) {
this.logger.warn(
`This node was tested with node.js version 16. To make sure that your node is running properly please update your node version!`,
);
Expand All @@ -74,12 +72,23 @@ class OTNode {
// set default user configuration filename
this.config.configFilename = '.origintrail_noderc';
}
const fileService = new FileService({ config: this.config });
const updateFilePath = fileService.getUpdateFilePath();
if (fs.existsSync(updateFilePath)) {
this.config.otNodeUpdated = true;
fileService.removeFile(updateFilePath).catch((error) => {
this.logger.warn(`Unable to remove update file. Error: ${error}`);
});
}
}

async initializeDependencyContainer() {
this.container = await DependencyInjection.initialize();
initializeDependencyContainer() {
this.container = DependencyInjection.initialize();
DependencyInjection.registerValue(this.container, 'config', this.config);
DependencyInjection.registerValue(this.container, 'logger', this.logger);
DependencyInjection.registerValue(this.container, 'constants', constants);
DependencyInjection.registerValue(this.container, 'blockchainQueue', queue);
DependencyInjection.registerValue(this.container, 'tripleStoreQueue', queue);

this.logger.info('Dependency injection module is initialized');
}
Expand Down Expand Up @@ -212,6 +221,16 @@ class OTNode {
}
}

async initializeWatchdog() {
try {
const watchdogService = this.container.resolve('watchdogService');
await watchdogService.initialize();
this.logger.info('Watchdog service initialized');
} catch (e) {
this.logger.warn(`Watchdog service initialization failed. Error message: ${e.message}`);
}
}

async savePrivateKeyAndPeerIdInUserConfigurationFile(privateKey) {
const configurationFilePath = path.join(appRootPath.path, '..', this.config.configFilename);
const configFile = JSON.parse(await fs.promises.readFile(configurationFilePath));
Expand Down Expand Up @@ -278,4 +297,4 @@ class OTNode {
}
}

export default OTNode;
module.exports = OTNode;
Loading

0 comments on commit 0391a72

Please sign in to comment.