<commit_before>import fs from 'fs';
import path from 'path';
import { spawn, exec } from 'child_process';
import isRunning from 'is-running';

// Launch Rethink
(() => {
  const path_rethinkdb_pid = path.resolve(__dirname, '../../rethinkdb.pid');
  function startRethinkDB() {
    const path_rethinkdb = process.platform === 'win32' ? '../../external/rethinkdb/rethinkdb' : '../../external/rethinkdb/build/release/rethinkdb';
    const child = spawn(
      path.resolve(__dirname, path_rethinkdb),
      ['--http-port', 8081],
      {
        detached: true,
        stdio: [
          'ignore',
          'ignore',
          // fs.openSync(path.resolve(__dirname, '../../rethinkdb_out.log'), 'a'),
          'ignore',
          // fs.openSync(path.resolve(__dirname, '../../rethinkdb_err.log'), 'a'),
        ],
      }
    );

    fs.writeFile(
      path_rethinkdb_pid,
      child.pid,
      (err) => {
        if (err) {
          throw err;
        }
      }
    );
    child.unref();
    console.log(`Started Rethinkdb (${child.pid})`);
  }

  fs.exists(path_rethinkdb_pid, exists => {
    if (exists) {
      fs.readFile(path_rethinkdb_pid, (err, pid) => {
        if (err) {
          throw err;
        }
        if (isRunning(pid)) {
          console.log(`RethinkDB is already running (${pid})...`);
        } else {
          startRethinkDB();
        }
      });
    }
    else {
      startRethinkDB();
    }
  });
})();


// Launch BeachJudge
(() => {
  const out = fs.openSync(path.resolve(__dirname, '../../beachjudge_out.log'), 'a');
  const err = fs.openSync(path.resolve(__dirname, '../../beachjudge_err.log'), 'a');
  const server = path.resolve(__dirname, '../../generated/node/index.js');
  const path_node = process.platform === 'win32' ? '../../external/nodejs/node' : '../../external/nodejs/bin/node';
  const node = path.resolve(__dirname, path_node);

  let child;
  if (process.platform === 'win32') {
    child = spawn(
      'cmd.exe',
      ['/c', node, server],
      {
        detached: true,
        stdio: ['ignore', out, err]
      }
    );
  }
  else {
    child = spawn(
      node,
      [server],
      {
        detached: true,
        stdio: [
          'ignore',
          out,
          err,
        ],
      }
    );
    console.log(`Started BeachJudge (${child.pid})`);
  }
  child.unref();
})();<commit_msg>Made beachjudge launch after rethinkdb<commit_after>import fs from 'fs';
import path from 'path';
import { spawn, exec } from 'child_process';
import isRunning from 'is-running';

var startBeachJudge = null;

// Launch Rethink
(() => {
  const path_rethinkdb_pid = path.resolve(__dirname, '../../rethinkdb.pid');
  function startRethinkDB() {
    const path_rethinkdb = process.platform === 'win32' ? '../../external/rethinkdb/rethinkdb' : '../../external/rethinkdb/build/release/rethinkdb';
    const child = spawn(
      path.resolve(__dirname, path_rethinkdb),
      ['--http-port', 8081],
      {
        detached: true,
        stdio: [
          'ignore',
          'ignore',
          // fs.openSync(path.resolve(__dirname, '../../rethinkdb_out.log'), 'a'),
          'ignore',
          // fs.openSync(path.resolve(__dirname, '../../rethinkdb_err.log'), 'a'),
        ],
      }
    );

    fs.writeFile(
      path_rethinkdb_pid,
      child.pid,
      (err) => {
        if (err) {
          throw err;
        }
      }
    );
    child.unref();
    console.log(`Started Rethinkdb (${child.pid})`);
    startBeachJudge();
  }

  fs.exists(path_rethinkdb_pid, exists => {
    if (exists) {
      fs.readFile(path_rethinkdb_pid, (err, pid) => {
        if (err) {
          throw err;
        }
        if (isRunning(pid)) {
          console.log(`RethinkDB is already running (${pid})...`);
        } else {
          startRethinkDB();
        }
      });
    }
    else {
      startRethinkDB();
    }
  });
})();


// Launch BeachJudge
(() => {
  startBeachJudge = function() {
  const out = fs.openSync(path.resolve(__dirname, '../../beachjudge_out.log'), 'a');
  const err = fs.openSync(path.resolve(__dirname, '../../beachjudge_err.log'), 'a');
  const server = path.resolve(__dirname, '../../generated/node/index.js');
  const path_node = process.platform === 'win32' ? '../../external/nodejs/node' : '../../external/nodejs/bin/node';
  const node = path.resolve(__dirname, path_node);

  let child;
  if (process.platform === 'win32') {
    child = spawn(
      'cmd.exe',
      ['/c', node, server],
      {
        detached: true,
        stdio: ['ignore', out, err]
      }
    );
    console.log(`Started BeachJudge`);
  }
  else {
    child = spawn(
      node,
      [server],
      {
        detached: true,
        stdio: [
          'ignore',
          out,
          err,
        ],
      }
    );
    console.log(`Started BeachJudge (${child.pid})`);
  }
  child.unref();
}
})();
{'fraction_non_alphanumeric': 0.1850709438618137, 'fraction_numerical': 0.004112687641373638, 'mean_word_length': 2.0192427063935443, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 13, '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': '5241341', 'n_tokens_mistral': 1620, 'n_tokens_neox': 1600, 'n_words': 296}