#!/bin/bash set -o nounset # Check if directory for monit logs exists if [ ! -d "$HOME/.planetmint-monit" ]; then mkdir -p "$HOME/.planetmint-monit" fi monit_pid_path=${MONIT_PID_PATH:=$HOME/.planetmint-monit/monit_processes} monit_script_path=${MONIT_SCRIPT_PATH:=$HOME/.planetmint-monit/monit_script} monit_log_path=${MONIT_LOG_PATH:=$HOME/.planetmint-monit/logs} monitrc_path=${MONITRC_PATH:=$HOME/.monitrc} function usage() { cat <${monit_script_path} < /dev/null 2>&1 & echo \$! > \$2 popd ;; stop_planetmint) kill -2 \`cat \$2\` rm -f \$2 ;; start_tendermint) pushd \$4 nohup tendermint node >> \$3/tendermint.out.log 2>> \$3/tendermint.err.log & echo \$! > \$2 popd ;; stop_tendermint) kill -2 \`cat \$2\` rm -f \$2 ;; esac exit 0 EOF chmod +x ${monit_script_path} cat >${monit_script_path}_logrotate <${monitrc_path} < 200 MB then exec "${monit_script_path}_logrotate rotate_tendermint_logs ${monit_log_path}/tendermint.out.log $monit_pid_path/tendermint.pid" check file tendermint.err.log with path ${monit_log_path}/tendermint.err.log if size > 200 MB then exec "${monit_script_path}_logrotate rotate_tendermint_logs ${monit_log_path}/tendermint.err.log $monit_pid_path/tendermint.pid" EOF # Setting permissions for control file chmod 0700 ${monitrc_path} echo -e "Planetmint process manager configured!" set -o errexit