Steemit Witness Journey - (Un)useful Scripts
Although did not managed to produce a single block yet, the 'admin disease' made me think on how to prevent missing them :) In my witness journey, I wrote a few scripts to start/stop and watchdog the steemd process. The same principle is used for cli_wallet so I am not going to repeat, but the PID principle is clear. The helpful thing is auto-restart, and simulating CTRL + C to make clean exit with SIGINT Posix signal.
Start/Stop Script
#!/bin/sh
pid_r=`pgrep -u root steemd -o`
pid_f=`cat /home/steem/Pids/steemd.pid`
case $1 in
start)
if [ -z $pid_r ]
then
pkill -SIGINT steemd
sleep 10
/home/steem/steemd &
sleep 3
pid_y=`pgrep -u root steemd -o`
echo "PID is $pid_y"
echo "$pid_y" > /home/steem/Pids/steemd.pid
echo "Process started"
else
if [ "$pid_f" = "$pid_r" ]
then
echo "All OK"
else
echo "Wrong"
killall steemd
/home/steem/steemd --replay-blockchain &
pid_n=`pgrep -u root steemd -o`
echo "NEW PID $pid_n"
echo "$pid_n" > /home/steem/Pids/steemd.pid
echo "Process restarted"
fi
fi
;;
stop)
pkill -SIGINT steemd
echo > /home/steem/Pids/steemd.pid
;;
*)
echo "usage : /home/steem/Start/steemd.sh {start|stop}"
esac
If you ever wondered how to run something from Crontab that executes more frequently then a minute, here is a trick :)
Watchdoggy script
#!/bin/bash
#
# steemit watchdoggy
#
cd /home/steem
ulimit -n 100000
now=$(perl -e 'alarm shift @ARGV; exec @ARGV' 2 /home/steem/./steemd & | grep starting)
if [[ "$now" == *starting* ]]
then
echo "It's there!";
else
echo "Timeout";
logger "Having fun with Steemd again"
sendemail -f [email protected] -t [email protected] -u "Steemd Problem" -m "Having fun with server" -s aspmx.l.google.com:25
pkill -SIGINT steemd
sleep 10
killall steemd
./steemd
fi
sleep 15
now=$(perl -e 'alarm shift @ARGV; exec @ARGV' 2 /home/steem/./steemd & | grep starting)
if [[ "$now" == *starting* ]]
then
echo "It's there!";
else
echo "Timeout";
logger "Having fun with steemd again"
sendemail -f [email protected] -t [email protected] -u "Steemd Problem" -m "Having fun with server" -s aspmx.l.google.com:25
pkill -SIGINT steemd
sleep 10
killall steemd
./steemd
fi
sleep 15
now=$(perl -e 'alarm shift @ARGV; exec @ARGV' 2 /home/steem/./steemd & | grep starting)
if [[ "$now" == *starting* ]]
then
echo "It's there!";
else
echo "Timeout";
logger "Having fun with steemd again"
sendemail -f [email protected] -t [email protected] -u "Steemd Problem" -m "Having fun with server" -s aspmx.l.google.com:25
pkill -SIGINT steemd
sleep 10
killall steemd
./steemd
fi
Not nice at all, require a lot of work, but sharing in case someone finds useful :)
Want to vote in support? You can do it with unlocked cli_wallet by executing
vote_for_witness "yourusername" "crt" true true
or by casting a Vote by entering crt at the bottom of the page here https://steemit.com/~witnesses