Monit

From Bitcoin Wiki
Jump to: navigation, search

Running an monitoring bitcoind with monit

I recommend adding a user account for bitcoin:

 adduser --disabled-login bitcoin

Place the home directory (or at least the .bitcoin/wallet.dat) on an encrypted volume (e.g. cryptsetup). It is also recommended to have a separate wallet for every day use containing only a small amount of coins.

Optional: move your existing .bitcoin directory to the new user and change ownership

 sudo mv .bitcoin ~bitcoin;
 sudo chown -R bitcoin.bitcoin ~bitcoin/.bitcoin

Configure bitcoind in ~bitcoin/bitcoin.conf, you also need to set at least rpcuser and rpcpassword:

 pid=/home/bitcoin/.bitcoin/pid

Create a wrapper for bitcoind in ~bitcoin/bin/bitcoind

 export HOME="/home/bitcoin"
 exec /path/to/the/real/bitcoind "$@"

Optional: You may want to run bitcoind with a lower priority than your interactive applications:

 export HOME="/home/bitcoin"
 exec /usr/bin/nice /usr/bin/ionice -c 3 /path/to/the/real/bitcoind "$@"

Add the following lines to your monitrc (/etc/monitrc or /etc/monit/monitrc) and reload monit:

 check process bitcoind with pidfile /home/bitcoin/.bitcoin/pid
 start program = "/home/bitcoin/bin/bitcoind -daemon" as uid bitcoin and gid bitcoin
 stop program = "/home/bitcoin/bin/bitcoind stop" as uid bitcoin and gid bitcoin
 #if totalmem > 100 MB then restart

If your bitcoind is leaking memory you may want to enable the totalmem check (adjust amount for your needs).