<commit_before>#!/bin/sh -e

start() {
    mkdir _testdb
    cd _testdb
    echo keyfile > keyfile
    chmod 600 keyfile
    cp ../testdb/server.pem server.pem
    cp -a ../testdb/daemons .
    if ! mongod --help | grep -q -- --ssl; then
        rm -rf daemons/db3
    fi
    COUNT=$(ls daemons | wc -l)
    echo "Running daemons..."
    svscan daemons &
    SVSCANPID=$!
    echo $SVSCANPID > svscan.pid
    if ! kill -0 $SVSCANPID; then
        echo "Cannot execute svscan."
        exit 1
    fi
    echo "Starting $COUNT processes..."
    for i in $(seq 30); do
        UP=$(svstat daemons/* | grep ' up ' | grep -v ' [0-3] seconds' | wc -l)
        echo "$UP processes up..."
        if [ x$COUNT = x$UP ]; then
            echo "Running setup.js with mongo..."
            mongo --nodb ../testdb/init.js
            exit 0
        fi
        sleep 1
    done
    echo "Failed to start all processes. Check out what's up at $PWD now!"
    exit 1
}

stop() {
    if [ -d _testdb ]; then
        cd _testdb<commit_msg>Show svstat output on failures.<commit_after>#!/bin/sh -e

start() {
    mkdir _testdb
    cd _testdb
    echo keyfile > keyfile
    chmod 600 keyfile
    cp ../testdb/server.pem server.pem
    cp -a ../testdb/daemons .
    if ! mongod --help | grep -q -- --ssl; then
        rm -rf daemons/db3
    fi
    COUNT=$(ls daemons | wc -l)
    echo "Running daemons..."
    svscan daemons &
    SVSCANPID=$!
    echo $SVSCANPID > svscan.pid
    if ! kill -0 $SVSCANPID; then
        echo "Cannot execute svscan."
        exit 1
    fi
    echo "Starting $COUNT processes..."
    for i in $(seq 30); do
        UP=$(svstat daemons/* | grep ' up ' | grep -v ' [0-3] seconds' | wc -l)
        echo "$UP processes up..."
        if [ x$COUNT = x$UP ]; then
            echo "Running setup.js with mongo..."
            mongo --nodb ../testdb/init.js
            exit 0
        fi
        sleep 1
    done
    echo "Failed to start processes. svstat _testdb/daemons/* output:"
    svstat daemons/*
    exit 1
}

stop() {
    if [ -d _testdb ]; then
        cd _testdb
{'fraction_non_alphanumeric': 0.12518054886856042, 'fraction_numerical': 0.012518054886856042, 'mean_word_length': 1.6370558375634519, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 7, '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': '4767499', 'n_tokens_mistral': 753, 'n_tokens_neox': 713, 'n_words': 240}