I'm setting up Monit to monitor the Bitcoin daemon to make sure it runs 24/7 and restarts it if something goes wrong. The Bitcoin binary is at
/usr/local/bin/bitcoind, and the data directory is at
I have told Monit to monitor the daemon through the pid file
/var/run/bitcoind.pid every 2 minutes and start / stop the daemon as the user
bitcoin. However, this is where I've spent countless hours trying to figure what is wrong.
Because I do not have a startup / upstart script for
bitcoind, I have it directly pass commands to the binary itself, which can be seen with the following
set daemon 120 set logfile /var/log/monit.log check process bitcoind with pidfile "/var/run/bitcoind.pid" start program "/usr/local/bin/bitcoind -pid=/var/run/bitcoind.pid -datadir=/home/bitcoin/.bitcoin -daemon" as uid bitcoin and gid bitcoin stop program "/usr/local/bin/bitcoind stop" as uid bitcoin and gid bitcoin if failed port 8332 for 2 cycles then restart
When the system startups, I login as the user
bitcoin and initiate
ps -u bitcoin. Sure enough, the
bitcoind appears as running under my user. However, when I get Monit to display the status through
monit status, the response shows first as
execution failed, then
bitcoind is running and found that there is no such file named as
bitcoind.pid, which leaves me to think that the
bitcoind does not have sufficient permissions to create a
pid file in
/var/run while running as user
For an alternative solution, I left the pid file to created in the default location (
/home/bitcoin/.bitcoin/bitcoind.pid), but the root can not access it, which also leads to the same result.
/var/log/monit.log file provides no useful information, so have the 'wrappers' I've tried.
This can all be solved by running
root, however I am worried about security issues.