Skip to content

Commit

Permalink
Update monitoring defaults and don't overwrite existing conf files (#627
Browse files Browse the repository at this point in the history
)

* Update monitoring defaults to match geoserver defaults and don't overwrite existing logging/monitoring config files

* Revert logic to set/generate monitor and log file on each start, expose log options to allow user configuration

* Fix default log dir value and chown log dir
  • Loading branch information
alexkuretz authored Mar 16, 2024
1 parent 3c01ba1 commit 605a5a2
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 22 deletions.
7 changes: 7 additions & 0 deletions .env
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,13 @@ P12_FILE=letsencrypt.p12
PKCS12_PASSWORD='geoserver'
LETSENCRYPT_CERT_DIR=/etc/letsencrypt
CHARACTER_ENCODING='UTF-8'
# Geoserver monitoring and audit logging https://docs.geoserver.org/main/en/user/extensions/monitoring/audit.html
MONITORING_AUDIT_ENABLED=false
MONITORING_AUDIT_ROLL_LIMIT=20
RESET_MONITORING_LOGS=false
# Geoserver logging
GEOSERVER_LOG_PROFILE=DEFAULT_LOGGING
GEOSERVER_LOG_DIR=/opt/geoserver/data_dir/logs
# Clustering variables
# Activates clustering using JMS cluster plugin
CLUSTERING=False
Expand Down
4 changes: 2 additions & 2 deletions scripts/entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -121,8 +121,8 @@ if [[ ${RUN_AS_ROOT} =~ [Ff][Aa][Ll][Ss][Ee] ]];then
if [[ -d "${GEOSERVER_DATA_DIR}"/jdbcstore ]];then
chown -R "${USER_NAME}":"${GEO_GROUP_NAME}" "${GEOSERVER_DATA_DIR}"/jdbcstore
fi
if [[ -d "${GEOSERVER_DATA_DIR}"/logs ]];then
chown -R "${USER_NAME}":"${GEO_GROUP_NAME}" "${GEOSERVER_DATA_DIR}"/logs
if [[ -d "${GEOSERVER_LOG_DIR}" ]];then
chown -R "${USER_NAME}":"${GEO_GROUP_NAME}" "${GEOSERVER_LOG_DIR}"
fi
# hazel cluster
if [[ -d "${GEOSERVER_DATA_DIR}"/cluster ]];then
Expand Down
13 changes: 8 additions & 5 deletions scripts/env-data.sh
Original file line number Diff line number Diff line change
Expand Up @@ -293,10 +293,13 @@ if [ -z "${PROXY_BASE_URL_PARAMETRIZATION}" ]; then
PROXY_BASE_URL_PARAMETRIZATION=false
fi

if [ -z "${GEOSERVER_LOG_LEVEL}" ]; then
GEOSERVER_LOG_LEVEL=DEFAULT_LOGGING
if [ -z "${GEOSERVER_LOG_PROFILE}" ]; then
GEOSERVER_LOG_PROFILE=DEFAULT_LOGGING
fi

if [ -z "${GEOSERVER_LOG_DIR}" ]; then
GEOSERVER_LOG_DIR=/opt/geoserver/data_dir/logs
fi

if [ -z "${ACTIVATE_ALL_COMMUNITY_EXTENSIONS}" ]; then
ACTIVATE_ALL_COMMUNITY_EXTENSIONS=false
Expand Down Expand Up @@ -414,14 +417,14 @@ if [ -z "${GEOSERVER_REQUIRE_FILE}" ];then
fi

if [ -z "${RESET_MONITORING_LOGS}" ];then
RESET_MONITORING_LOGS=FALSE
RESET_MONITORING_LOGS=false
fi

if [ -z "${MONITORING_AUDIT_ENABLED}" ];then
MONITORING_AUDIT_ENABLED=true
MONITORING_AUDIT_ENABLED=false
fi
if [ -z "${MONITORING_AUDIT_ROLL_LIMIT}" ];then
MONITORING_AUDIT_ROLL_LIMIT=40
MONITORING_AUDIT_ROLL_LIMIT=20
fi
if [ -z "${MONITORING_STORAGE}" ];then
MONITORING_STORAGE=memory
Expand Down
27 changes: 13 additions & 14 deletions scripts/functions.sh
Original file line number Diff line number Diff line change
Expand Up @@ -385,7 +385,7 @@ function setup_logging() {
if [[ ${CLUSTERING} =~ [Tt][Rr][Uu][Ee] ]]; then
export LOG_PATH=${CLUSTER_CONFIG_DIR}/geoserver-${HOSTNAME}.log
else
export LOG_PATH=${GEOSERVER_DATA_DIR}/logs/geoserver-${HOSTNAME}.log
export LOG_PATH=${GEOSERVER_LOG_DIR}/geoserver.log
fi
envsubst < /build_data/log4j.properties > "${CATALINA_HOME}"/log4j.properties
fi
Expand All @@ -394,22 +394,21 @@ function setup_logging() {
}

function geoserver_logging() {
if [[ ${CLUSTERING} =~ [Tt][Rr][Uu][Ee] ]]; then
export LOG_PATH=${CLUSTER_CONFIG_DIR}/geoserver-${HOSTNAME}.log
else
create_dir "${GEOSERVER_DATA_DIR}"/logs
export LOG_PATH=${GEOSERVER_DATA_DIR}/logs/geoserver-${HOSTNAME}.log
fi
if [[ ${CLUSTERING} =~ [Tt][Rr][Uu][Ee] ]]; then
export LOG_PATH=${CLUSTER_CONFIG_DIR}/geoserver-${HOSTNAME}.log
else
create_dir "${GEOSERVER_LOG_DIR}"
export LOG_PATH=${GEOSERVER_LOG_DIR}/geoserver.log
fi

echo "
<logging>
<level>${GEOSERVER_LOG_LEVEL}</level>
<level>${GEOSERVER_LOG_PROFILE}</level>
<location>${LOG_PATH}</location>
<stdOutLogging>true</stdOutLogging>
</logging>
" > "${GEOSERVER_DATA_DIR}"/logging.xml


if [[ ! -f ${LOG_PATH} ]];then
touch "${LOG_PATH}"
fi
Expand Down Expand Up @@ -554,11 +553,11 @@ function entry_point_script {

function setup_monitoring() {

if [[ -f "${EXTRA_CONFIG_DIR}"/monitor.properties ]]; then
envsubst < "${EXTRA_CONFIG_DIR}"/monitor.properties > "${GEOSERVER_DATA_DIR}"/monitoring/monitor.properties
else
if [[ -f "${EXTRA_CONFIG_DIR}"/monitor.properties ]]; then
envsubst < "${EXTRA_CONFIG_DIR}"/monitor.properties > "${GEOSERVER_DATA_DIR}"/monitoring/monitor.properties
else

cat > "${GEOSERVER_DATA_DIR}"/monitoring/monitor.properties <<EOF
cat > "${GEOSERVER_DATA_DIR}"/monitoring/monitor.properties <<EOF
audit.enabled=${MONITORING_AUDIT_ENABLED}
audit.roll_limit=${MONITORING_AUDIT_ROLL_LIMIT}
storage=${MONITORING_STORAGE}
Expand All @@ -568,7 +567,7 @@ maxBodySize=${MONITORING_BODY_SIZE}
bboxLogCrs=${MONITORING_BBOX_LOG_CRS}
bboxLogLevel=${MONITORING_BBOX_LOG_LEVEL}
EOF
fi
fi

}

Expand Down
2 changes: 1 addition & 1 deletion scripts/start.sh
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,7 @@ export REQUEST_TIMEOUT PARALLEL_REQUEST GETMAP REQUEST_EXCEL SINGLE_USER GWC_REQ
setup_control_flow


export GEOSERVER_LOG_LEVEL
export GEOSERVER_LOG_PROFILE
geoserver_logging


Expand Down

0 comments on commit 605a5a2

Please sign in to comment.