<commit_before>/**
 * Created by archheretic on 28.02.17.
 */
let path = require('path');
let namesPath = path.join(__dirname, 'storage', 'users.json');
let nodesPath = path.join(__dirname, 'storage', 'nodes.json');
let fs = require('fs');
let User = require('./models/user.model');
let Node = require('./models/node.model');
let https = require('http');
let publicIp = require('public-ip');


let myIp;
let myPort = parseInt(process.env.PORT);
publicIp.v4().then(ip => {
    myIp = ip;
});

let minPort = 8000;
let maxPort = 8999;

let pullMaster = {
    start: function() {

        // waits 3 seconds and then starts pulling down node list every 6 seconds.
        setTimeout(function () {
            setInterval(function () {
                pullNodes();
            }, 6000);
        }, 3000);

        // pulls down name lists every 6 seconds.
        setInterval(function () {
            pullNames();
        }, 6000);

    //  this.pullNodes();
    }
};

module.exports = pullMaster;

function pullNames() {
    console.log("pull name lists");

    fs.readFile(nodesPath, 'utf8', function (err, data) {
        if (err) throw err;
        let obj = JSON.parse(data);
        let ip;
        let port;
        for (let i = 0, len = obj.nodes.length; i < len; i++) {
            //console.log(obj.nodes[i]);
            ip = obj.nodes[i].ip;
            port = obj.nodes[i].port;
     // if we go back to ports
    //        for (let port = 0; port < ports.length; port++)
    //        {
            if (ip != myIp && port != myPort) {
                doGetUsersRequest(ip, port);
            }
        }
    });
}

function pullNodes() {
    console.log("pull node lists");

    fs.readFile(nodesPath, 'utf8', function (err, data) {
        if (err) throw err;
        let obj = JSON.parse(data);
        let ip;
        for (let i = 0, len = obj.nodes.length; i < len; i++) {
            ip = obj.nodes[i].ip;<commit_msg>fix an error that made the ubuntu server crash.<commit_after>/**
 * Created by archheretic on 28.02.17.
 */
let path = require('path');
let namesPath = path.join(__dirname, 'storage', 'users.json');
let nodesPath = path.join(__dirname, 'storage', 'nodes.json');
let fs = require('fs');
let User = require('./models/user.model');
let Node = require('./models/node.model');
let https = require('http');
let publicIp = require('public-ip');


let myIp;
let myPort = parseInt(process.env.PORT);
publicIp.v4().then(ip => {
    myIp = ip;
});

let minPort = 8000;
let maxPort = 8999;

let pullMaster = {
    start: function() {

        // waits 3 seconds and then starts pulling down node list every 6 seconds.
        setTimeout(function () {
            setInterval(function () {
                pullNodes();
            }, 6000);
        }, 3000);

        // pulls down name lists every 6 seconds.
        setInterval(function () {
            pullNames();
        }, 6000);

    //  this.pullNodes();
    }
};

module.exports = pullMaster;

function pullNames() {
    console.log("pull name lists");

    fs.readFile(nodesPath, 'utf8', function (err, data) {
        if (err) {
            console.log(err);
            return;
        }
        let obj = JSON.parse(data);
        let ip;
        let port;
        for (let i = 0, len = obj.nodes.length; i < len; i++) {
            //console.log(obj.nodes[i]);
            ip = obj.nodes[i].ip;
            port = obj.nodes[i].port;
     // if we go back to ports
    //        for (let port = 0; port < ports.length; port++)
    //        {
            if (ip != myIp && port != myPort) {
                doGetUsersRequest(ip, port);
            }
        }
    });
}

function pullNodes() {
    console.log("pull node lists");

    fs.readFile(nodesPath, 'utf8', function (err, data) {
        if (err) {
            console.log(err);
            return;
        }
        let obj = JSON.parse(data);
        let ip;
        for (let i = 0, len = obj.nodes.length; i < len; i++) {
            ip = obj.nodes[i].ip;
{'fraction_non_alphanumeric': 0.15525, 'fraction_numerical': 0.0175, 'mean_word_length': 1.9505899705014749, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '462903', 'n_tokens_mistral': 1291, 'n_tokens_neox': 1221, 'n_words': 343}