<commit_before>#!/bin/bash

echo "[Start] ViSH check daemons script"

: ${RAILS_ENV="production"} #to get the environment variable or define it
: ${RAILS_ROOT="/u/apps/vish/current"}
: ${SPHINX_PID_FILE="$RAILS_ROOT/log/searchd.$RAILS_ENV.pid"} 
: ${GOD_PID_FILE="/var/run/god/resque-worker-0.pid"}


check_sphinx=false
check_god=false

if [ $# -eq 0 ]; then
	check_sphinx=true
	check_god=true
else
	for ARG in $*
	do
		if [ $ARG = "sphinx" ]; then
			check_sphinx=true
		elif [ $ARG = "god" ]; then
			check_god=true
		fi
	done
fi

rvm_installed=false
if [ -s "$HOME/.rvm/scripts/rvm" ] || [ -s "/usr/local/rvm/scripts/rvm" ] ; then
	rvm_installed=true
	source /etc/profile.d/rvm.sh
fi


if $check_sphinx; then
	run_sphinx=false
	if test -f $SPHINX_PID_FILE; then
		sphinx_ps="$(ps -p `cat $SPHINX_PID_FILE` -o comm=)"
		if [ "$sphinx_ps" != "searchd" ]; then
			run_sphinx=true
			rm $SPHINX_PID_FILE
		fi
	else
		run_sphinx=true
	fi

	if $run_sphinx; then
		echo "Let's run sphinx!"
		cd $RAILS_ROOT
		bundle exec rake ts:rebuild RAILS_ENV=$RAILS_ENV
		#fix sphinx pid file permissions
		/bin/chmod 777 $RAILS_ROOT/log/searchd*
	else<commit_msg>Update check daemon script<commit_after>#!/bin/bash

echo "[Start] ViSH check daemons script"

: ${RAILS_ENV="production"} #to get the environment variable or define it
: ${RAILS_ROOT="/u/apps/vish/current"}
: ${SPHINX_PID_FILE="$RAILS_ROOT/log/searchd.$RAILS_ENV.pid"} 
: ${GOD_PID_FILE="/var/run/god/resque-worker-0.pid"}


check_sphinx=false
check_god=false

if [ $# -eq 0 ]; then
	check_sphinx=true
	check_god=true
else
	for ARG in $*
	do
		if [ $ARG = "sphinx" ]; then
			check_sphinx=true
		elif [ $ARG = "god" ]; then
			check_god=true
		fi
	done
fi

rvm_installed=false
if [ -s "$HOME/.rvm/scripts/rvm" ] || [ -s "/usr/local/rvm/scripts/rvm" ] ; then
	rvm_installed=true
	source /etc/profile.d/rvm.sh
fi


if $check_sphinx; then
	run_sphinx=false
	if test -f $SPHINX_PID_FILE; then
		sphinx_ps="$(ps -p `cat $SPHINX_PID_FILE` -o comm=)"
		if [ "$sphinx_ps" != "searchd" ]; then
			run_sphinx=true
			rm $SPHINX_PID_FILE
		fi
	else
		run_sphinx=true
	fi

	if $run_sphinx; then
		echo "Let's run sphinx!"
		cd $RAILS_ROOT
		bundle exec rake ts:rebuild RAILS_ENV=$RAILS_ENV
		#fix sphinx pid file permissions
		/bin/chmod 777 $RAILS_ROOT/log/searchd*
		/bin/chgrp www-data $RAILS_ROOT/log/searchd*
	else
{'fraction_non_alphanumeric': 0.14134125636672326, 'fraction_numerical': 0.004244482173174873, 'mean_word_length': 4.036324786324786, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 1, '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': '911347', 'n_tokens_mistral': 1112, 'n_tokens_neox': 1031, 'n_words': 215}