Bitcoin Forum
May 08, 2024, 01:23:48 AM *
News: Latest Bitcoin Core release: 27.0 [Torrent]
 
   Home   Help Search Login Register More  
Pages: [1]
  Print  
Author Topic: Bitcoind server wrapper  (Read 965 times)
SlickTheNick (OP)
Full Member
***
Offline Offline

Activity: 220
Merit: 100


View Profile
February 25, 2013, 07:12:41 PM
Last edit: February 28, 2013, 03:44:23 AM by SlickTheNick
 #1

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


Looking for a way to get some bitcoins for free? Check out http://earnfreebitcoins.com !
Get easy bitcoins at  https://coincontroller.com?r=eaef398b5 !
1715131428
Hero Member
*
Offline Offline

Posts: 1715131428

View Profile Personal Message (Offline)

Ignore
1715131428
Reply with quote  #2

1715131428
Report to moderator
"You Asked For Change, We Gave You Coins" -- casascius
Advertised sites are not endorsed by the Bitcoin Forum. They may be unsafe, untrustworthy, or illegal in your jurisdiction.
1715131428
Hero Member
*
Offline Offline

Posts: 1715131428

View Profile Personal Message (Offline)

Ignore
1715131428
Reply with quote  #2

1715131428
Report to moderator
1715131428
Hero Member
*
Offline Offline

Posts: 1715131428

View Profile Personal Message (Offline)

Ignore
1715131428
Reply with quote  #2

1715131428
Report to moderator
1715131428
Hero Member
*
Offline Offline

Posts: 1715131428

View Profile Personal Message (Offline)

Ignore
1715131428
Reply with quote  #2

1715131428
Report to moderator
hamdi
Hero Member
*****
Offline Offline

Activity: 826
Merit: 500



View Profile
February 26, 2013, 01:34:37 AM
 #2

linux or windows?
hamdi
Hero Member
*****
Offline Offline

Activity: 826
Merit: 500



View Profile
February 26, 2013, 01:38:16 AM
 #3


#!/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.
SlickTheNick (OP)
Full Member
***
Offline Offline

Activity: 220
Merit: 100


View Profile
February 28, 2013, 01:57:14 AM
 #4

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?

Looking for a way to get some bitcoins for free? Check out http://earnfreebitcoins.com !
Get easy bitcoins at  https://coincontroller.com?r=eaef398b5 !
hamdi
Hero Member
*****
Offline Offline

Activity: 826
Merit: 500



View Profile
February 28, 2013, 02:11:10 AM
 #5

you could run a command that ask the server for the balance, if it takes too long, kill the server and restart.
payb.tc
Hero Member
*****
Offline Offline

Activity: 812
Merit: 1000



View Profile
February 28, 2013, 02:21:44 AM
 #6

perhaps instead of persisting with bitcoind, you could consider this option:

cURL
+
http://blockchain.info/api/blockchain_wallet_api
SlickTheNick (OP)
Full Member
***
Offline Offline

Activity: 220
Merit: 100


View Profile
February 28, 2013, 03:26:18 AM
Last edit: February 28, 2013, 03:44:35 AM by SlickTheNick
 #7

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


Looking for a way to get some bitcoins for free? Check out http://earnfreebitcoins.com !
Get easy bitcoins at  https://coincontroller.com?r=eaef398b5 !
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.19 | SMF © 2006-2009, Simple Machines Valid XHTML 1.0! Valid CSS!