<commit_before>import { P2pService } from './services/p2p';
import { Storage } from './services/storage';
import { Worker } from './services/worker';
import { Api } from './services/api';
import cluster = require('cluster');
import parseArgv from './utils/parseArgv';
let args = parseArgv([], ['DEBUG']);

const startServices = async () => {
  await Storage.start({});
  await Worker.start();
  P2pService.startConfiguredChains();
};

const runMaster = async() => {
  await startServices();
  // start the API on master if we are in debug
  if(args.DEBUG){
    Api.start();
  }
};

const runWorker = async() => {
  // don't run any workers when in debug mode
  if(!args.DEBUG){
    // Api will automatically start storage if it isn't already running
    Api.start();
  }
}

const start = async() => {
  if(cluster.isMaster){
    await runMaster();
  } else{<commit_msg>handle unhandled rejections<commit_after>import { P2pService } from './services/p2p';
import { Storage } from './services/storage';
import { Worker } from './services/worker';
import { Api } from './services/api';
import cluster = require('cluster');
import parseArgv from './utils/parseArgv';
let args = parseArgv([], ['DEBUG']);

process.on('unhandledRejection', (error) => {
  console.error('Unhandled Rejection at:', error.stack || error)
});

const startServices = async () => {
  await Storage.start({});
  await Worker.start();
  P2pService.startConfiguredChains();
};

const runMaster = async() => {
  await startServices();
  // start the API on master if we are in debug
  if(args.DEBUG){
    Api.start();
  }
};

const runWorker = async() => {
  // don't run any workers when in debug mode
  if(!args.DEBUG){
    // Api will automatically start storage if it isn't already running
    Api.start();
  }
}

const start = async() => {
  if(cluster.isMaster){
    await runMaster();
  } else{
{'fraction_non_alphanumeric': 0.16220556745182013, 'fraction_numerical': 0.0032119914346895075, 'mean_word_length': 3.767857142857143, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 12, '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': '2869732', 'n_tokens_mistral': 575, 'n_tokens_neox': 582, 'n_words': 172}