BitShares Forum
Main => Technical Support => Topic started by: kuro112 on January 08, 2016, 05:55:56 am
-
Hey guys, im just posting some personal scripts i made here, they arent perfect, they will require you to adjust and to have set things up using my tutorial,
https://bitsharestalk.org/index.php/topic,19612.msg251784.html#msg251784
however if you run bts daemons like i do and are getting annoyed by the lack of any type of auto-update system, let this help!
note i will be altering it to pull git revisions automatically soon, and detect soft changes to the blockchain for syncing, for now its literally just a process watchdog.
if you have any additions or you want to fix my code (im obviously really bad with bash, so its welcome) please feel free to post them here, i wont take it personally, i know my bash is amateur at best.
Watchdog:
echo "Watching RPC";
while true
do
while true
do
netstat -tuna | grep 8090
if [ $? -ne 1 ]
then
UPDATE=0
else
break
fi
done
netstat -tuna | grep 8090;
while [ $? -ne 0 ]
do
echo "RPC Failed - Attempting to start"
sh "/root/btsr"
sleep 5
netstat -tuna | grep 8090;
if [ $? -ne 0 ]
then
if [ "$UPDATE" -eq 1 ]
then
echo "RPC Start Failed, Updating"
UPDATE=1
sh /root/update
fi
fi
netstat -tuna | grep 8090;
if [ $? -ne 1 ]
then
break
fi
done
sleep 1
done
Run Witness and Wallet
BOOST_ROOT=$HOME/opt/boost_1_57_0;
cd /root/witness-2;
screen -S witness -X stuff $'\003'`echo '\015'`
screen -S witness -X stuff "witness_node `echo '\015'`";
echo "Waiting for sync";
sleep 3;
netstat -tuna | grep 8090;
while [ $? -ne 0 ]
do
netstat -tuna | grep 8090;
done
while [ $? -ne 1 ]
do
screen -S wallet -X stuff $'\003'`echo '\015'`
cd /root/testwallet;
echo "BOOST_ROOT=$HOME/opt/boost_1_57_0"
screen -S wallet -X stuff "cli_wallet -H 0.0.0.0:8092 -w `echo '\015'`"
sleep 5;
echo "Starting Wallet"
break
done
Update System
rm -rf bitshares-2;
BOOST_ROOT=$HOME/opt/boost_1_57_0
git clone https://github.com/bitshares/bitshares-2;
cd bitshares-2;
git submodule update --init --recursive;
cmake -DBOOST_ROOT="$BOOST_ROOT" -DCMAKE_BUILD_TYPE=Release .;
make;
make install
quick FAQ:
why the hell is it 3 bash scripts?
well simple answer is that i wanted to be able to run them independently.
wtf screens? and why are you stuffing them instead of running -dmS??
well i like to be able to manually manage them, and without a tmux wrapper to make it respond to screen commands, tmux is annoying to use.
the advantage of creating and stuffing a screen manually is repeated control when the application dies, you can still access the screen.
what is this actually doing?
it uses netstat to check if the wallet is running, if not, starts or updates it depending on the result.
it will be updated to use githubs version checking system soon, and other improvements.
can i just run this straight off?
You should probably edit some stuff like the directorates the script cd's to, ill make these variables later.
how do i actually use this??
make sure you followed my tutorial for building an rpc from scratch,
make sure you make screen instances of witness and wallet,
and that the wallet and witness are NOT running
screen -dmS wallet
screen -dmS witness
then your ready to run the watchdog (which will find your wallet and witness not running)
(i name mine just wd)
screen -dmS watchdog sh wd
and thats it, to check on it, which will give you annoying output, do
screen -x watchdog
please note that this is just my first attempt, while i run and manage servers for a living i do not spend a lot of time automating functions on them,
and my bash scripting skills are pretty minimal like i said before, any input is welcome and also many improvements will be made as time goes on.
let me know if this helps at all, and i hope it does.
-
Thank you for sharing these scripts.. I'll be adapting them to my needs.