<commit_before>import { Logger, RestClient } from "chipster-nodejs-core";
import { of } from "rxjs";
import { mergeMap } from "rxjs/operators";
import { VError } from "verror";
import ReplaySession from "./replay-session";

const ArgumentParser = require("argparse").ArgumentParser;
const logger = Logger.getLogger(__filename, "logs/chipster.log");
const schedule = require("node-schedule");
const serveIndex = require("serve-index");
const express = require("express");
const path = require("path");

export default class ReplayServer {
  startTime: Date;
  resultsPath: string;
  influxdbUrl: string;

  constructor() {
    Logger.addLogFile();

    this.parseCommand();
  }

  parseCommand() {
    let parser = new ArgumentParser({
      version: "0.0.1",
      addHelp: true,
      description: "Chipster session replay server"
    });

    parser.addArgument(["URL"], { help: "url of the app server" });
    parser.addArgument(["--username", "-u"], {
      help: "username for the server"
    });
    parser.addArgument(["--password", "-p"], {
      help: "password for the server"
    });
    parser.addArgument(["--results", "-r"], {
      help:
        "replay session prefix and test result directory (both cleared automatically)",
      defaultValue: "results"
    });
    parser.addArgument(["--temp", "-t"], {
      help: "temp directory",
      defaultValue: ReplaySession.tempDefault
    });
    parser.addArgument(["--schedule", "-s"], {
      help:
        "how often to run a test sets, in format CRON_SCHEDULE:FILTER1[ FILTER2...]. Run immediately If CRON_SCHEDULE is empty. Filter is a prefix of the session name or a specail string 'example-sessions'. ",
      action: "append"
    });
    parser.addArgument(["--influxdb", "-i"], {
      help: "influxdb url for statistics, e.g. http://influxdb:8086/write?db=db"
    });
    parser.addArgument(["--port", "-P"], {
      help: "HTTP port for serving the result files",
      defaultValue: "9000"
    });

    let args = parser.parseArgs();

    this.startTime = new Date();

    logger.info(
      "start server for sharing the result files, in port",
      args.port
    );

    ReplaySession.mkdirIfMissing(args.results);
    ReplaySession.mkdirIfMissing(args.temp);

    var app = express();
    app.use(
      "/",
      express.static("results"),
      serveIndex("results", { icons: true, view: "details" })
    );
    app.listen(parseInt(args.port));

    let schedules = args.schedule;<commit_msg>Delete an obsolete startTime field<commit_after>import { Logger, RestClient } from "chipster-nodejs-core";
import { of } from "rxjs";
import { mergeMap } from "rxjs/operators";
import { VError } from "verror";
import ReplaySession from "./replay-session";

const ArgumentParser = require("argparse").ArgumentParser;
const logger = Logger.getLogger(__filename, "logs/chipster.log");
const schedule = require("node-schedule");
const serveIndex = require("serve-index");
const express = require("express");
const path = require("path");

export default class ReplayServer {
  resultsPath: string;
  influxdbUrl: string;

  constructor() {
    Logger.addLogFile();

    this.parseCommand();
  }

  parseCommand() {
    let parser = new ArgumentParser({
      version: "0.0.1",
      addHelp: true,
      description: "Chipster session replay server"
    });

    parser.addArgument(["URL"], { help: "url of the app server" });
    parser.addArgument(["--username", "-u"], {
      help: "username for the server"
    });
    parser.addArgument(["--password", "-p"], {
      help: "password for the server"
    });
    parser.addArgument(["--results", "-r"], {
      help:
        "replay session prefix and test result directory (both cleared automatically)",
      defaultValue: "results"
    });
    parser.addArgument(["--temp", "-t"], {
      help: "temp directory",
      defaultValue: ReplaySession.tempDefault
    });
    parser.addArgument(["--schedule", "-s"], {
      help:
        "how often to run a test sets, in format CRON_SCHEDULE:FILTER1[ FILTER2...]. Run immediately If CRON_SCHEDULE is empty. Filter is a prefix of the session name or a specail string 'example-sessions'. ",
      action: "append"
    });
    parser.addArgument(["--influxdb", "-i"], {
      help: "influxdb url for statistics, e.g. http://influxdb:8086/write?db=db"
    });
    parser.addArgument(["--port", "-P"], {
      help: "HTTP port for serving the result files",
      defaultValue: "9000"
    });

    let args = parser.parseArgs();

    logger.info(
      "start server for sharing the result files, in port",
      args.port
    );

    ReplaySession.mkdirIfMissing(args.results);
    ReplaySession.mkdirIfMissing(args.temp);

    // start a web server for the results
    var app = express();
    app.use(
      "/",
      express.static("results"),
      serveIndex("results", { icons: true, view: "details" })
    );
    app.listen(parseInt(args.port));

    let schedules = args.schedule;
{'fraction_non_alphanumeric': 0.15141129032258063, 'fraction_numerical': 0.005241935483870968, 'mean_word_length': 3.1864978902953585, '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': '4493162', 'n_tokens_mistral': 1495, 'n_tokens_neox': 1443, 'n_words': 403}