#!/bin/bash # Copyright © 2020 Interplanetary Database Association e.V., # Planetmint and IPDB software contributors. # SPDX-License-Identifier: (Apache-2.0 AND CC-BY-4.0) # Code is Apache-2.0 and docs are CC-BY-4.0 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 \ --p2p.laddr "tcp://0.0.0.0:26656" \ --rpc.laddr "tcp://0.0.0.0:26657" \ --proxy_app="tcp://0.0.0.0:26658" \ --consensus.create_empty_blocks=false \ --p2p.pex=false >> \$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