Commit 247c3833 authored by Eriksson Monteiro's avatar Eriksson Monteiro

fix launch tangled ad module

parent 9f16436a
...@@ -11,6 +11,8 @@ import logManager from './core/log-manager'; ...@@ -11,6 +11,8 @@ import logManager from './core/log-manager';
import fs from 'fs'; import fs from 'fs';
import path from 'path'; import path from 'path';
import os from 'os'; import os from 'os';
const childProcess = require('child_process');
let tangledProcess;
const argv = require('yargs') const argv = require('yargs')
.options({ .options({
...@@ -154,13 +156,31 @@ const checkPIDFile = () => { ...@@ -154,13 +156,31 @@ const checkPIDFile = () => {
}); });
}; };
const checkTangledAdvertisementProcess = () => {
request.get('https://localhost:15555/', {
strictSSL: false,
encoding: null
}, (err, response, body) => {
if (err || response.statusCode !== 200) {
tangledProcess = childProcess.spawn(process.execPath, [`${__dirname}/tangled-advertisement.js`, '--pid-file', './tangled-advertisement.pid'], { stdio: 'ignore' });
}
setTimeout(() => checkTangledAdvertisementProcess(), 60000);
});
}
eventBus.on('wallet_unlock', () => {
if (!tangledProcess) {
tangledProcess = childProcess.spawn(process.execPath, [`${__dirname}/tangled-advertisement.js`, '--pid-file', './tangled-advertisement.pid'], { stdio: 'ignore' });
setTimeout(() => checkTangledAdvertisementProcess(), 60000);
}
});
logger.initialize().then(() => { logger.initialize().then(() => {
console.log('starting millix-core'); console.log('starting millix-core');
checkPIDFile() checkPIDFile()
.then(() => db.initialize()) .then(() => db.initialize())
.then(() => configLoader.cleanConfigsFromDatabase()) .then(() => configLoader.load())
.then(() => configLoader.load(false)) .then(() => services.initialize({auto_create_wallet: false}))
.then(() => services.initialize())
.then(() => { .then(() => {
logManager.logSize = 1000; logManager.logSize = 1000;
if (config.MODE_TEST) { if (config.MODE_TEST) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment