You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@accumulo.apache.org by el...@apache.org on 2015/06/30 06:14:23 UTC

accumulo git commit: ACCUMULO-2287 Retain a fixed number of .out and .err files on process restart.

Repository: accumulo
Updated Branches:
  refs/heads/master b10c172ea -> d513f826b


ACCUMULO-2287 Retain a fixed number of .out and .err files on process restart.


Project: http://git-wip-us.apache.org/repos/asf/accumulo/repo
Commit: http://git-wip-us.apache.org/repos/asf/accumulo/commit/d513f826
Tree: http://git-wip-us.apache.org/repos/asf/accumulo/tree/d513f826
Diff: http://git-wip-us.apache.org/repos/asf/accumulo/diff/d513f826

Branch: refs/heads/master
Commit: d513f826bda0b996e0243c6a33fe4e1ac49f05cf
Parents: b10c172
Author: Josh Elser <el...@apache.org>
Authored: Thu Jun 25 12:42:38 2015 -0400
Committer: Josh Elser <el...@apache.org>
Committed: Mon Jun 29 21:38:40 2015 -0400

----------------------------------------------------------------------
 assemble/bin/config-server.sh           |  3 +++
 assemble/bin/start-daemon.sh            | 27 ++++++++++++++++++++++++++-
 assemble/conf/templates/accumulo-env.sh |  2 ++
 3 files changed, 31 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/accumulo/blob/d513f826/assemble/bin/config-server.sh
----------------------------------------------------------------------
diff --git a/assemble/bin/config-server.sh b/assemble/bin/config-server.sh
index dad3e81..92aa4a6 100755
--- a/assemble/bin/config-server.sh
+++ b/assemble/bin/config-server.sh
@@ -80,3 +80,6 @@ fi
 if [[ -z "${ACCUMULO_IDENT_STRING}" ]]; then
   export ACCUMULO_IDENT_STRING="$USER"
 fi
+
+# The number of .out and .err files to retain
+export ACCUMULO_NUM_OUT_FILES=${ACCUMULO_NUM_OUT_FILES:-5}

http://git-wip-us.apache.org/repos/asf/accumulo/blob/d513f826/assemble/bin/start-daemon.sh
----------------------------------------------------------------------
diff --git a/assemble/bin/start-daemon.sh b/assemble/bin/start-daemon.sh
index 507fcb0..54fb55f 100755
--- a/assemble/bin/start-daemon.sh
+++ b/assemble/bin/start-daemon.sh
@@ -28,6 +28,24 @@ script=$( basename "$SOURCE" )
 
 usage="Usage: start-daemon.sh <host> <service>"
 
+rotate_log () {
+  logfile=$1;
+  max_retained=$2;
+  if [[ ! $max_retained =~ ^[0-9]+$ ]] || [[ $max_retained -lt 1 ]] ; then
+    echo "ACCUMULO_NUM_OUT_FILES should be a positive number, but was '$max_retained'"
+    exit 1
+  fi
+
+  if [ -f "$logfile" ]; then # rotate logs
+    while [ $max_retained -gt 1 ]; do
+      prev=`expr $max_retained - 1`
+      [ -f "$logfile.$prev" ] && mv -f "$logfile.$prev" "$logfile.$max_retained"
+      max_retained=$prev
+    done
+    mv -f "$logfile" "$logfile.$max_retained";
+  fi
+}
+
 if [[ $# -ne 2 ]]; then
   echo $usage
   exit 2
@@ -78,8 +96,15 @@ if [ "${ACCUMULO_WATCHER}" = "true" ]; then
    COMMAND="${bin}/accumulo_watcher.sh ${LOGHOST}"
 fi
 
+OUTFILE="${ACCUMULO_LOG_DIR}/${SERVICE}_${LOGHOST}.out"
+ERRFILE="${ACCUMULO_LOG_DIR}/${SERVICE}_${LOGHOST}.err"
+
+# Rotate the .out and .err files
+rotate_log "$OUTFILE" ${ACCUMULO_NUM_OUT_FILES}
+rotate_log "$ERRFILE" ${ACCUMULO_NUM_OUT_FILES}
+
 # Fork the process, store the pid
-nohup ${NUMA_CMD} "$COMMAND" "${SERVICE}" --address "${ADDRESS}" >"${ACCUMULO_LOG_DIR}/${SERVICE}_${LOGHOST}.out" 2>"${ACCUMULO_LOG_DIR}/${SERVICE}_${LOGHOST}.err" < /dev/null &
+nohup ${NUMA_CMD} "$COMMAND" "${SERVICE}" --address "${ADDRESS}" >"$OUTFILE" 2>"$ERRFILE" < /dev/null &
 echo $! > ${PID_FILE}
 
 # Check the max open files limit and selectively warn

http://git-wip-us.apache.org/repos/asf/accumulo/blob/d513f826/assemble/conf/templates/accumulo-env.sh
----------------------------------------------------------------------
diff --git a/assemble/conf/templates/accumulo-env.sh b/assemble/conf/templates/accumulo-env.sh
index a8cb917..8a9ff15 100644
--- a/assemble/conf/templates/accumulo-env.sh
+++ b/assemble/conf/templates/accumulo-env.sh
@@ -76,3 +76,5 @@ export OOM_RETRIES="5"
 export ZKLOCK_TIMESPAN="600"
 export ZKLOCK_RETRIES="5"
 
+# The number of .out and .err files per process to retain
+# export ACCUMULO_NUM_OUT_FILES=5