I'm trying to get /usr/bin/bitcoind to start on boot but without success.
I have this script on /etc/init/bitcoind.conf
description "bitcoind"
start on filesystem
stop on runlevel [!2345]
oom never
expect daemon
respawn
respawn limit 10 60 # 10 times in 60 seconds
script
user=andre
home=/home/$user
cmd=/usr/bin/bitcoind
pidfile=$home/.bitcoin/bitcoind.pid
# Don't change anything below here unless you know what you're doing
[[ -e $pidfile && ! -d "/proc/$(cat $pidfile)" ]] && rm $pidfile
[[ -e $pidfile && "$(cat /proc/$(cat $pidfile)/cmdline)" != $cmd* ]] && rm $pidfile
exec start-stop-daemon --start -c $user --chdir $home --pidfile $pidfile --starta $cmd -b -m
end scriptAfter creating this script I've run the command: sudo initctl reload-configuration
When I restart Ubuntu the "bitcoind" does not start. I only can start "bitcoind" running manually the command:
sudo start bitcoindAny clues on how to start "bitcoind" on boot?
12 Answers
So I finally got things working on an Ubuntu 14.04 server. Here's what the final, working /etc/init/bitcoind.conf looks like:
description "bitcoind"
start on filesystem
stop on runlevel [!2345]
oom score -500
expect fork
respawn
respawn limit 10 60 # 10 times in 60 seconds
script user=bitcoind home=/home/$user cmd=$home/bin/bitcoind pidfile=$home/bitcoind.pid # Don't change anything below here unless you know what you're doing [[ -e $pidfile && ! -d "/proc/$(cat $pidfile)" ]] && rm $pidfile [[ -e $pidfile && "$(cat /proc/$(cat $pidfile)/cmdline)" != $cmd* ]] && rm $pidfile exec start-stop-daemon --start -c $user --chdir $home --pidfile $pidfile -m --startas $cmd
end scriptIt was basically just a lot of guess and check work to get this working. Here's the important bit:
expect forkEssentially, this is telling upstart how many times the target process will be forked while starting. If you tell it wrong, it'll hang while starting. Read here for the specifics on this.
One other, minor change:
oom score -500Instead of:
oom neverNot such a critical change, but after reading about upstart a bit and from seeing a suggestion in a stackoverflow answer, oom never should almost never be used. See here for more info.
This is what I did.
Check the file /etc/rc.local with cat /etc/rc.local
You will see something like this
#!/bin/sh -e
#
# rc.local
#
# This script is executed at the end of each multiuser runlevel.
# Make sure that the script will "exit 0" on success or any other
# value on error.
#
# In order to enable or disable this script just change the execution
# bits.
#
# By default this script does nothing.Then just add this line
bitcoind -daemon You can execute bitcoind with the options -datadir=/path/to/data or -conf=/path/to/bitcoin.conf if you need it.