From 8fc5c28b4a2be95f5e1a7736ffa6577409fc789c Mon Sep 17 00:00:00 2001 From: Ahmed Muawia Khan Date: Thu, 26 Jul 2018 12:34:45 +0200 Subject: [PATCH] Fixing the remaining TODOs for #2410 - Settling on default path of control file: $HOME/.monitrc - Handling overwriting of control file interactively - Save BigchainDB logs in the current directory i.e. from which BigchainDB is launched. - Print default values in help - Cleanup TBD items --- bigchaindb/log.py | 10 +++--- pkg/scripts/bigchaindb-monit-config | 49 ++++++++++++++++++----------- 2 files changed, 35 insertions(+), 24 deletions(-) diff --git a/bigchaindb/log.py b/bigchaindb/log.py index 47892509..9fca6508 100644 --- a/bigchaindb/log.py +++ b/bigchaindb/log.py @@ -3,10 +3,10 @@ import logging from bigchaindb.common.exceptions import ConfigurationError from logging.config import dictConfig as set_logging_config -from os.path import expanduser, join +import os -DEFAULT_LOG_DIR = expanduser('~') +DEFAULT_LOG_DIR = os.getcwd() BENCHMARK_LOG_LEVEL = 15 @@ -40,7 +40,7 @@ DEFAULT_LOGGING_CONFIG = { }, 'file': { 'class': 'logging.handlers.RotatingFileHandler', - 'filename': join(DEFAULT_LOG_DIR, 'bigchaindb.log'), + 'filename': os.path.join(DEFAULT_LOG_DIR, 'bigchaindb.log'), 'mode': 'w', 'maxBytes': 209715200, 'backupCount': 5, @@ -49,7 +49,7 @@ DEFAULT_LOGGING_CONFIG = { }, 'errors': { 'class': 'logging.handlers.RotatingFileHandler', - 'filename': join(DEFAULT_LOG_DIR, 'bigchaindb-errors.log'), + 'filename': os.path.join(DEFAULT_LOG_DIR, 'bigchaindb-errors.log'), 'mode': 'w', 'maxBytes': 209715200, 'backupCount': 5, @@ -58,7 +58,7 @@ DEFAULT_LOGGING_CONFIG = { }, 'benchmark': { 'class': 'logging.handlers.RotatingFileHandler', - 'filename': 'bigchaindb-benchmark.log', + 'filename': os.path.join(DEFAULT_LOG_DIR, 'bigchaindb-benchmark.log'), 'mode': 'w', 'maxBytes': 209715200, 'backupCount': 5, diff --git a/pkg/scripts/bigchaindb-monit-config b/pkg/scripts/bigchaindb-monit-config index a4667a39..189172b2 100644 --- a/pkg/scripts/bigchaindb-monit-config +++ b/pkg/scripts/bigchaindb-monit-config @@ -11,12 +11,6 @@ if [[ -n "$NOUNSET" ]]; then set -o nounset fi -# TBD: Defaults to $HOME, otherwise if we want to address: -# pid path could be /etc/pid_path -# monit_script could be -# log_path /var/log/monit/ -# exec path(for monitrc) could be /etc/monitrc, /usr/local/etc/monitrc - # Check if directory for monit logs exists if [ ! -d "$HOME/.bigchaindb-monit" ]; then mkdir -p "$HOME/.bigchaindb-monit" @@ -25,7 +19,7 @@ fi monit_pid_path=${MONIT_PID_PATH:=$HOME/.bigchaindb-monit/monit_processes} monit_script_path=${MONIT_SCRIPT_PATH:=$HOME/.bigchaindb-monit/monit_script} monit_log_path=${MONIT_LOG_PATH:=$HOME/.bigchaindb-monit/logs} -monit_exec_path=${MONIT_EXEC_PATH:=$HOME} +monit_exec_path=${MONIT_EXEC_PATH:=$HOME/.monitrc} function usage() { cat <${monit_exec_path}/.monitrc <${monit_exec_path} <