[ 
https://issues.apache.org/jira/browse/CASSANDRA-17773?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17619358#comment-17619358
 ] 

Claude Warren commented on CASSANDRA-17773:
-------------------------------------------

The problem in this case was an old {{cassandra-env.sh}} (which does not get 
patched). But it could just as easily been a {{cassandra.in.sh}} script.

It seem to me that there is at least 1 and possibly more environment vars that 
are critical to understanding how the environment is configured and have 
default values. I think that perhaps we should have a block of script that 
checks the set value against the default and logs a warning (similar to mck's 
example above) whenever they don't match. This will provide a warning in cases 
where it is accidental and confirmation in cases where it is desired.

I also note that not all scripts include {{cassandra-env.sh }}only 
{{cassandra}}, {{debug-cql}}, and {{nodetool}} do.
The CASSANDRA_INCLUDE block is found in {{cassandra}}, {{debug-cql}}, 
{{nodetool}}, {{sstableloader}}, {{sstablescrub}}, {{sstableupgrade}}, 
{{sstableutil}}, {{sstableverify}}.
It seems like this should be consistent.

I think that an include file (cassandra-conf) in the CASSANDRA_HOME/bin 
directory containing:

{noformat}
CASSANDRA_CONF=Y

if [ "x$CASSANDRA_HOME" = "x" ]; then
    CASSANDRA_HOME="`dirname "$0"`/.."
fi

# The directory where Cassandra's configs live (required)
if [ "x$CASSANDRA_CONF" = "x" ]; then
    CASSANDRA_CONF="$CASSANDRA_HOME/conf"
fi

if [ "x$CASSANDRA_INCLUDE" = "x" ]; then
    # Locations (in order) to use when searching for an include file.
    for include in "`dirname "$0"`/cassandra.in.sh" \
                   "$HOME/.cassandra.in.sh" \
                   /usr/share/cassandra/cassandra.in.sh \
                   /usr/local/share/cassandra/cassandra.in.sh \
                   /opt/cassandra/cassandra.in.sh; do
        if [ -r "$include" ]; then
            CASSANDRA_INCLUDE=$include
            . "$include"
            break
        fi
    done
# ...otherwise, source the specified include.
elif [ -r "$CASSANDRA_INCLUDE" ]; then
    . "$CASSANDRA_INCLUDE"
fi

if [ -z "$CASSANDRA_CONF " ]; then
    echo "You must set the CASSANDRA_CONF var" >&2
    exit 1
fi

## Add variable checks here like

if [ -z "$CASSANDRA_LOG_DIR" ]; then
  echo "CASSANDRA_LOG_DIR should have been set to a default value in 
$CASSANDRA_INCLUDE some log files will be found elsewhere, please fix 
$CASSANDRA_INCLUDE"
  CASSANDRA_LOG_DIR=$CASSANDRA_HOME/logs
fi

{noformat}


Finally, modify conf/cassandra-env.sh to change:

{noformat}
# Sets the path where logback and GC logs are written.
if [ "x$CASSANDRA_LOG_DIR" = "x" ] ; then
    CASSANDRA_LOG_DIR="$CASSANDRA_HOME/logs"
fi
{noformat}
to
{noformat}
# Sets the path where logback and GC logs are written.
if [ "x$CASSANDRA_CONF" = "x" ] ; then
    .  ../bin/cassandra-conf
fi
{noformat}



> Incorrect cassandra.logdir on Debian systems
> --------------------------------------------
>
>                 Key: CASSANDRA-17773
>                 URL: https://issues.apache.org/jira/browse/CASSANDRA-17773
>             Project: Cassandra
>          Issue Type: Bug
>          Components: Packaging
>            Reporter: Eric Evans
>            Priority: Normal
>              Labels: lhf
>             Fix For: 3.0.x, 3.11.x, 4.0.x, 4.1-rc
>
>
> The Debian packaging patches bin/cassandra to use /var/log/cassandra for 
> logs, it does so conditionally however, only if CASSANDRA_LOG_DIR is unset. 
> This occurs _after_ cassandra-env.sh is sourced though, which also sets 
> CASSANDRA_LOG_DIR if unset (to $CASSANDRA_HOME/logs).  The result is that 
> -Dcassandra.lodir is set to /usr/share/cassandra/logs on Debian systems.



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscr...@cassandra.apache.org
For additional commands, e-mail: commits-h...@cassandra.apache.org

Reply via email to