Set default directories to $HOME/.bigchaindb-monit

- Fix config utils log info, previously misleading even if
  .bigchaindb file not present.
This commit is contained in:
Ahmed Muawia Khan 2018-07-25 17:17:01 +02:00
parent 755795bf46
commit bd6e6b7ec3
2 changed files with 23 additions and 6 deletions

View File

@ -99,6 +99,7 @@ def file_config(filename=None):
if filename is None: if filename is None:
filename = CONFIG_DEFAULT_PATH filename = CONFIG_DEFAULT_PATH
logger.error(filename)
logger.debug('file_config() will try to open `{}`'.format(filename)) logger.debug('file_config() will try to open `{}`'.format(filename))
with open(filename) as f: with open(filename) as f:
try: try:

View File

@ -17,9 +17,14 @@ fi
# log_path /var/log/monit/ # log_path /var/log/monit/
# exec path(for monitrc) could be /etc/monitrc, /usr/local/etc/monitrc # exec path(for monitrc) could be /etc/monitrc, /usr/local/etc/monitrc
monit_pid_path=${MONIT_PID_PATH:=$HOME/monit_processes} # Check if directory for monit logs exists
monit_script_path=${MONIT_SCRIPT_PATH:=$HOME/monit_script} if [ ! -d "$HOME/.bigchaindb-monit" ]; then
monit_log_path=${MONIT_LOG_PATH:=$HOME/logs} mkdir -p "$HOME/.bigchaindb-monit"
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}
function usage() { function usage() {
@ -46,7 +51,7 @@ function usage() {
ENV[MONIT_EXEC_PATH] || --monit-exec-path PATH ENV[MONIT_EXEC_PATH] || --monit-exec-path PATH
Absolute path to the directory with monit control file. Absolute path to the directory to run the script form.
-h|--help -h|--help
Show this help and exit. Show this help and exit.
@ -97,6 +102,7 @@ if [ ! -d "$monit_pid_path" ]; then
fi fi
cat >${monit_script_path} <<EOF cat >${monit_script_path} <<EOF
#!/bin/bash
case \$1 in case \$1 in
start_bigchaindb) start_bigchaindb)
@ -160,3 +166,13 @@ EOF
# Setting permissions for control file # Setting permissions for control file
chmod 0700 ${monit_exec_path}/.monitrc chmod 0700 ${monit_exec_path}/.monitrc
# Kill background processes on exit
trap exit_trap EXIT
function exit_trap {
exit $?
}
# Exit on any errors so that errors don't compound and kill if any services already started
echo -e "BigchainDB process manager configured!"
set -o errexit