<commit_before><?php

/**
 * Check if slaves fingerprint has changed
 *
 * @param array $slaves Array of slaves with EC2 instance ID as array key
 * @param string $fileLocation Location of file storing slaves configuration
 * @return boolean
 */
function hasSlavesChanged($slaves, $fileLocation) 
{
    $old = array();
    if (file_exists($fileLocation)) {
        $old = unserialize(file_get_contents($fileLocation));
        
        if (!is_writable($fileLocation)) {
            trigger_error($fileLocation . ' is not writable.', E_USER_ERROR);
        }
    }
    
    sort($old);
    sort($slaves);
    
    if ($old == $slaves) {
        return false;
    }

    file_put_contents($fileLocation, serialize($slaves));
    return true;
}


/**
 * Check if Lsyncd is still running fine
 * 
 * @param array $APP_CONF Application configuration
 */
function isLSyncdRunning($APP_CONF)
{
    $processManager = new ProcessManager();
    $pid = $processManager->execProcess($APP_CONF['path_to_lsyncd'] . ' ' . $APP_CONF['data_dir'] . 'lsyncd.conf.lua');
    echo $pid;
    exit();
}<commit_msg>Function to check if Lsyncd is still alive<commit_after><?php

use Liip\ProcessManager\ProcessManager;

/**
 * Check if slaves fingerprint has changed
 *
 * @param array $slaves Array of slaves with EC2 instance ID as array key
 * @param string $fileLocation Location of file storing slaves configuration
 * @return boolean
 */
function hasSlavesChanged($slaves, $fileLocation) 
{
    $old = array();
    if (file_exists($fileLocation)) {
        $old = unserialize(file_get_contents($fileLocation));
        
        if (!is_writable($fileLocation)) {
            trigger_error($fileLocation . ' is not writable.', E_USER_ERROR);
        }
    }
    
    sort($old);
    sort($slaves);
    
    if ($old == $slaves) {
        return false;
    }

    file_put_contents($fileLocation, serialize($slaves));
    return true;
}


/**
 * Check if Lsyncd is still alive
 * If it is not, start it
 *
 * @param array $APP_CONF Application configuration
 */
function keepLSyncdAlive($APP_CONF)
{
    $lock = new PidFile(new ProcessManager(), $APP_CONF['data_dir'] . 'lsyncd.pid');
    
    if ($lock->isProcessRunning()) {
        echo "Lsyncd is still running fine.";
        return;
    }
    
    $lock->acquireLock();
    $pid = $lock->execProcess($APP_CONF['path_to_lsyncd'] . ' ' . $APP_CONF['data_dir'] . 'lsyncd.conf.lua');
    
    return;
}
{'fraction_non_alphanumeric': 0.13023829087921118, 'fraction_numerical': 0.0008216926869350862, 'mean_word_length': 3.106239460370995, 'pattern_counts': {'":': 0, '<': 5, '<?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': '293230', 'n_tokens_mistral': 757, 'n_tokens_neox': 748, 'n_words': 189}