<commit_before>#!/bin/bash
#
# Simple Redis init.d script conceived to work on Linux systems
# as it does use of the /proc filesystem.

### BEGIN INIT INFO
# Provides:             redis<%= @service_id %>
# Required-Start:       $network $syslog
# Required-Stop:        $network $syslog
# Default-Start:        2 3 4 5
# Default-Stop:         0 1 6
# Short-Description:    redis<%= @service_id %> (<%= @id %>)
# Description:          redis<%= @service_id %> port=<%= @port %> id=<%= @id %> install_prefix=<%= @install_prefix %>
### END INIT INFO

REDISPORT=<%= @port %>
EXEC="<%= @install_prefix %>/bin/redis-server"
CLIEXEC="<%= @install_prefix %>/bin/redis-cli"
LOGFILE=/var/log/redis/redis_${REDISPORT}.log
PIDFILE=/var/run/redis/redis_${REDISPORT}.pid
CONF="/etc/redis/redis_${REDISPORT}.conf"

#ulimit setup on init execution
ULIMIT=$(ulimit -n)
#sum maxclients setting in all redis instances and /1024
redis_totalconns=$(($(grep maxclients /etc/redis/redis*.conf | grep -v '^[[:space:]]*#' |awk {'print $2'} | awk '{ sum+=$1} END {print sum}') / 1024))

RETVAL=0

if [ $redis_totalconns -eq 0 ]; then
    redis_maxconns=10240
else
    ### This seems redundant, but its to prevent non 1024 increment ulimits
    redis_maxconns=$((1024 * $redis_totalconns))
fi

#if the current ulimit is less than redis_maxconns, bump it up on process execution
if [ $ULIMIT -lt $redis_maxconns ] || [ $ULIMIT -eq $redis_maxconns ]; then<commit_msg>Fixed redis_totalconns calculation when there are no maxclients specified<commit_after>#!/bin/bash
#
# Simple Redis init.d script conceived to work on Linux systems
# as it does use of the /proc filesystem.

### BEGIN INIT INFO
# Provides:             redis<%= @service_id %>
# Required-Start:       $network $syslog
# Required-Stop:        $network $syslog
# Default-Start:        2 3 4 5
# Default-Stop:         0 1 6
# Short-Description:    redis<%= @service_id %> (<%= @id %>)
# Description:          redis<%= @service_id %> port=<%= @port %> id=<%= @id %> install_prefix=<%= @install_prefix %>
### END INIT INFO

REDISPORT=<%= @port %>
EXEC="<%= @install_prefix %>/bin/redis-server"
CLIEXEC="<%= @install_prefix %>/bin/redis-cli"
LOGFILE=/var/log/redis/redis_${REDISPORT}.log
PIDFILE=/var/run/redis/redis_${REDISPORT}.pid
CONF="/etc/redis/redis_${REDISPORT}.conf"

#ulimit setup on init execution
ULIMIT=$(ulimit -n)
#sum maxclients setting in all redis instances and /1024
redis_totalconns=$(($(grep maxclients /etc/redis/redis*.conf | grep -v '^[[:space:]]*#' |awk {'print $2'} | awk 'BEGIN {sum=0} {sum+=$1} END {print sum}') / 1024))

RETVAL=0

if [ $redis_totalconns -eq 0 ]; then
    redis_maxconns=10240
else
    ### This seems redundant, but its to prevent non 1024 increment ulimits
    redis_maxconns=$((1024 * $redis_totalconns))
fi

#if the current ulimit is less than redis_maxconns, bump it up on process execution
if [ $ULIMIT -lt $redis_maxconns ] || [ $ULIMIT -eq $redis_maxconns ]; then
{'fraction_non_alphanumeric': 0.1599320882852292, 'fraction_numerical': 0.022071307300509338, 'mean_word_length': 4.061855670103093, 'pattern_counts': {'":': 0, '<': 23, '<?xml version=': 0, '>': 23, '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': '3721169', 'n_tokens_mistral': 1144, 'n_tokens_neox': 1046, 'n_words': 293}