<commit_before><?php

// ----- only run from command line -----
if($argc < 1) die;

include_once("../../config.php");

$idletime = 150;

$procfile = file_get_contents(BASE_FILE."capture/stream/logs/procinfo");

$tmp = explode("|", $procfile);
$pid = $tmp[0];
$last = $tmp[1];

//echo "no updates in " . (time() - $last) . " seconds<br />";

exec("pgrep php", $proclist, $return); 							// apache2 if script is started by Apache

logit("controller.log","script called - pid:" . $pid . "  idle:" . (time() - $last));

if(in_array($pid,$proclist)) {

	//echo "process " . $pid . " running";

	if($last < time() - $idletime) {

		exec("kill " . $pid);

		logit("controller.log","script was idle for more than " . $idletime . " seconds - killing and starting");

		sleep(16);

		passthru("php ".BASE_FILE."capture/stream/capture.php > /dev/null 2>&1 &");
	}

} else {

	logit("controller.log","script was not running - starting");

	passthru("php ".BASE_FILE."capture/stream/capture.php > /dev/null 2>&1 &");
}


function logit($file,$message) {

	$file = BASE_FILE."capture/stream/logs/" . $file;
	$message = date("Y-m-d H:i:s") . " " . $message . "\n";
	file_put_contents($file, $message, FILE_APPEND);
}

?><commit_msg>changed sleep time<commit_after><?php

// ----- only run from command line -----
if($argc < 1) die;

include_once("../../config.php");

$idletime = 150;

$procfile = file_get_contents(BASE_FILE."capture/stream/logs/procinfo");

$tmp = explode("|", $procfile);
$pid = $tmp[0];
$last = $tmp[1];

//echo "no updates in " . (time() - $last) . " seconds<br />";

exec("pgrep php", $proclist, $return); 							// apache2 if script is started by Apache

logit("controller.log","script called - pid:" . $pid . "  idle:" . (time() - $last));

if(in_array($pid,$proclist)) {

	//echo "process " . $pid . " running";

	if($last < time() - $idletime) {

		exec("kill " . $pid);

		logit("controller.log","script was idle for more than " . $idletime . " seconds - killing and starting");

		sleep(2);

		passthru("php ".BASE_FILE."capture/stream/capture.php > /dev/null 2>&1 &");
	}

} else {

	logit("controller.log","script was not running - starting");

	passthru("php ".BASE_FILE."capture/stream/capture.php > /dev/null 2>&1 &");
}


function logit($file,$message) {

	$file = BASE_FILE."capture/stream/logs/" . $file;
	$message = date("Y-m-d H:i:s") . " " . $message . "\n";
	file_put_contents($file, $message, FILE_APPEND);
}

?>
{'fraction_non_alphanumeric': 0.22295081967213115, 'fraction_numerical': 0.010245901639344262, 'mean_word_length': 3.4788990825688075, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 15, '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': '5804988', 'n_tokens_mistral': 944, 'n_tokens_neox': 894, 'n_words': 192}