forked from steemit/steem
-
Notifications
You must be signed in to change notification settings - Fork 0
/
paas-sv-run.sh
24 lines (22 loc) · 900 Bytes
/
paas-sv-run.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
#!/bin/bash
# if the writer node dies, kill runsv causing the container to exit
STEEMD_PID=`pgrep -f p2p-endpoint`
if [[ ! $? -eq 0 ]]; then
echo NOTIFYALERT! steemd has quit unexpectedly, checking for core dump and then starting a new instance..
sleep 30
SAVED_PID=`cat /tmp/steemdpid`
if [[ -e /tmp/core.$SAVED_PID ]]; then
gdb --batch --quiet -ex "thread apply all bt full" -ex "quit" /usr/local/steemd-full/bin/steemd /tmp/core.$SAVED_PID >> /tmp/stacktrace
STACKTRACE=`cat /tmp/stacktrace`
echo NOTIFYALERT! steemd stacktrace from coredump:
for ((i=0;i<${#STACKTRACE};i+=120)); do
echo "${STACKTRACE:i:120}"
done
CORE_FILE_NAME=coredump-`date '+%Y%m%d-%H%M%S'`.$SAVED_PID
aws s3 cp /tmp/core.$SAVED_PID s3://$S3_BUCKET/$CORE_FILE_NAME
fi
RUN_SV_PID=`pgrep -f /etc/service/steemd`
kill -9 $RUN_SV_PID
fi
# check on this every 10 seconds
sleep 10