Bitcoin Forum

Bitcoin => Bitcoin Technical Support => Topic started by: SlickTheNick on February 25, 2013, 07:12:41 PM



Title: Bitcoind server wrapper
Post by: SlickTheNick on February 25, 2013, 07:12:41 PM
Hey all, iv been having some issues with my Bitcoind server crashing due to running out of RAM. Obvious solution would be to just get more RAM, but currently cant afford that for at least a few weeks. Does anyone know of a wrapper that would automatically restart bitcoind once it detects a crash? Or maybe a tutorial/resource that would show me how to write up a quick script that would accomplish this? Major PITA to manually restart it each time.

also this is in linux.

*edit* Heres the solution I came up with. Fairly simple bash script that checks the server every 10 minutes.

Code:
#!/bin/bash

function checkServer {
local CHECK=$(pgrep bitcoind)

if [[ -z "$CHECK" ]]
then
echo 0
else
echo 1
fi
}

while sleep 600; do

if [ `checkServer` == 0 ]
then
echo Restarting Server
bitcoind -daemon
else
echo All is well
fi

done



Title: Re: Bitcoind server wrapper
Post by: hamdi on February 26, 2013, 01:34:37 AM
linux or windows?


Title: Re: Bitcoind server wrapper
Post by: hamdi on February 26, 2013, 01:38:16 AM

#!/bin/bash
while true
do
sleep 600
killall -9 bitcoind
sleep 5
/etc/init.d/bitcoind start
done






this would kill the bitcoind every 10 minutes and restart it.


Title: Re: Bitcoind server wrapper
Post by: SlickTheNick on February 28, 2013, 01:57:14 AM
Sorry I forgot to mention, yes in linux. Would there be a way to say, run the script, which starts the server, and then checks to see if the server is still running say every 10 minutes, if not restart server?


Title: Re: Bitcoind server wrapper
Post by: hamdi on February 28, 2013, 02:11:10 AM
you could run a command that ask the server for the balance, if it takes too long, kill the server and restart.


Title: Re: Bitcoind server wrapper
Post by: payb.tc on February 28, 2013, 02:21:44 AM
perhaps instead of persisting with bitcoind, you could consider this option:

cURL
+
http://blockchain.info/api/blockchain_wallet_api


Title: Re: Bitcoind server wrapper
Post by: SlickTheNick on February 28, 2013, 03:26:18 AM
Actually, I figured it out. Did some digging around and finally figured out how to write bash scripts. The script I made is posted below, il update the OP with it as well

Code:
#!/bin/bash

function checkServer {
local CHECK=$(pgrep bitcoind)

if [[ -z "$CHECK" ]]
then
echo 0
else
echo 1
fi
}

while sleep 600; do

if [ `checkServer` == 0 ]
then
echo Restarting Server
bitcoind -daemon
else
echo All is well
fi

done