Skip to content
Snippets Groups Projects
Commit 3b281d73 authored by Robert Martin-Legene's avatar Robert Martin-Legene
Browse files

bfa ps, bfa top

parent 8c44652e
No related branches found
No related tags found
No related merge requests found
...@@ -66,6 +66,40 @@ function pidsfromsigfiles ...@@ -66,6 +66,40 @@ function pidsfromsigfiles
echo "${pids# }" echo "${pids# }"
} }
register_subcommand 'ps' 'psprocs' 'Show processes relating to known .pid files'
function psprocs
{
pids=$(pidsfromsigfiles)
if [ -z "$pids" ]
then
echo "There are no processes of interest." >&2
exit 1
fi
# shellcheck disable=SC2086
ps -p ${pids// /,}
}
register_subcommand 'top' 'topprocs' 'Show relevant processes in top.'
function topprocs
{
pids=$(pidsfromsigfiles)
if [ -z "$pids" ]
then
echo "There are no processes of interest." >&2
exit 1
fi
# shellcheck disable=SC2086
local args pid
args=
# shellcheck disable=SC2086
for pid in $pids
do
args="$args -p $pid"
done
# shellcheck disable=SC2086
exec top $args
}
function sendsig function sendsig
{ {
local signal pids local signal pids
...@@ -79,7 +113,8 @@ function sendsig ...@@ -79,7 +113,8 @@ function sendsig
# shellcheck disable=SC2086 # shellcheck disable=SC2086
ps -p ${pids// /,} ps -p ${pids// /,}
echo "Sending ${signal} signal to pid $pids." echo "Sending ${signal} signal to pid $pids."
kill "$signal" "$pids" || true # shellcheck disable=SC2086
kill "$signal" $pids || true
} }
register_subcommand 'kill' 'killbfastuff' 'Kill BFA background processes (no questions asked).' register_subcommand 'kill' 'killbfastuff' 'Kill BFA background processes (no questions asked).'
...@@ -173,9 +208,11 @@ function importdb ...@@ -173,9 +208,11 @@ function importdb
done done
geth --networkid "${BFANETWORKID}" --datadir "${BFANODEDIR}" --syncmode "full" --gcmode "archive" import <( geth --networkid "${BFANETWORKID}" --datadir "${BFANODEDIR}" --syncmode "full" --gcmode "archive" import <(
n=1 n=1
while gzip -dc "bfa2018-1Mblocksstartingat${n}.block.export.gz" 2>/dev/null printf -v filename 'bfa2018.blocks.%09d-%09d.export.gz' "$n" "$((n + delta - 1))"
while gzip -dc "$filename" 2>/dev/null
do do
n=$(( n + 1000000 )) n=$((n + delta))
printf -v filename 'bfa2018.blocks.%09d-%09d.export.gz' "$n" "$((n + delta - 1))"
done done
true true
) )
...@@ -336,10 +373,15 @@ function truncatelog ...@@ -336,10 +373,15 @@ function truncatelog
true > "${BFANODEDIR}/log" true > "${BFANODEDIR}/log"
} }
register_subcommand 'bfageth' 'bfageth' 'Start geth for BFA.' register_subcommand 'geth' 'bfageth' 'Start geth for BFA.'
function bfageth function bfageth
{ {
exec geth --config "${BFANETWORKDIR}/conf.bfa2018.local+full+archive" "$@" if [ -z "$*" ]
then
echo "You should not run this command without any arguments. Start the background processes with start.sh instead." >&2
exit 1
fi
exec geth --config "${BFANETWORKDIR}/config.localhost+full+archive" "$@"
} }
function bfaadmin function bfaadmin
...@@ -388,13 +430,13 @@ function main ...@@ -388,13 +430,13 @@ function main
eval ${commands[$cmd]} "$*" eval ${commands[$cmd]} "$*"
;; ;;
'admin.sh') 'admin.sh')
bfaadmin "$*" bfaadmin "$@"
;; ;;
'bfalog.sh') 'bfalog.sh')
bfatail bfatail
;; ;;
'bfageth') 'bfageth')
bfageth "$*" bfageth "$@"
exit 1 exit 1
esac esac
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment