<commit_before>"use strict";

require('babel/register')({
  only: /src/
});

var request = require('request')
  , server = require('./server')

const API_URL = process.env.EDITORSNOTES_API_URL || 'http://localhost:8001'


console.log('Starting server...')
console.log('Verifying Editors\' Notes API address at ' + API_URL + '...')


request(API_URL, { headers: { Accept: 'application/json' }}, function (err) {
  if (err) {
    if (err.code === 'ECONNREFUSED') {
      throw new Error('Could not connect to Editor\'s Notes API server at ' + API_URL);
    } else {
      throw err;
    }
  }

  console.log('Server started');
  server.serve()
});

<commit_msg>Retry connecting to EN API server on initial failure<commit_after>"use strict";

require('babel/register')({
  only: /src/
});

var request = require('request')
  , server = require('./server')

const API_URL = process.env.EDITORSNOTES_API_URL || 'http://localhost:8001'

console.log('Starting server...')
console.log('Verifying Editors\' Notes API address at ' + API_URL + '...')

function start() {
  request(API_URL, { headers: { Accept: 'application/json' }}, function (err) {
    if (err) {
      if (err.code === 'ECONNREFUSED') {
        console.error('Could not connect to Editor\'s Notes API server at ' + API_URL);
        console.error('Retrying in 5 seconds...');

        setTimeout(start, 5000);
        return;
      } else {
        throw err;
      }
    }

    console.log('Server started');
    server.serve()
  });
}

start();

{'fraction_non_alphanumeric': 0.1699867197875166, 'fraction_numerical': 0.008632138114209827, 'mean_word_length': 3.2212885154061626, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '3784788', 'n_tokens_mistral': 494, 'n_tokens_neox': 478, 'n_words': 120}