Title: bitcoind upstart configuration - ubuntu Post by: frozen on July 03, 2011, 03:12:44 AM For those running ubuntu, you may be familiar with upstart (http://upstart.ubuntu.com), a replacement for sysvinit style booting (/etc/init.d/*).
Configuration files for upstart are stored under /etc/init/*.conf. I've written the following one for bitcoind: Code: description "bitcoind" Put the above configuration in /etc/init/bitcoind.conf, then run sudo initctl reload-configuration. To start bitcoind, run sudo start bitcoind. To stop bitcoind, run sudo stop bitcoind. You'll probably want to change the user, cmd and pidfile to something that matches your configuration, or you can use the following as a template: /home/bitcoinuser /home/bitcoinuser/bitcoind.pid /home/bitcoinuser/bin/bitcoind Enjoy Title: Re: bitcoind upstart configuration - ubuntu Post by: jorijnsmit on June 22, 2013, 08:48:15 PM Thanks, works like a charm!
Regarding configuration I had to use these values: Code: home=/home/$user Title: Re: bitcoind upstart configuration - ubuntu Post by: cosix on July 01, 2013, 02:49:32 PM i can't get the bitcoind.pid file to show up what do i do?
Title: Re: bitcoind upstart configuration - ubuntu Post by: happyface on November 12, 2013, 07:13:42 PM Thanks for posting this upstart config frozen (it's the first result on Google). If bitcoind is not mission-critical to your server, I highly recommend setting the nice level as well.
Code: exec start-stop-daemon --start -c $user --chdir $home --pidfile $pidfile --startas $cmd -b --nicelevel 15 -m Title: Re: bitcoind upstart configuration - ubuntu Post by: alexykot on June 11, 2014, 01:45:15 PM Hi
I've tried to use this script and it works fine for starting the daemon on system boot, but doesn't help to restart it if process fails, although it should, as it has "respawn" stanza. I've tried numerous ways to do that and sorted a few minor issues on the way, but this is still not working for me. Any ideas how to make it restart automatically with upstart? regards Alex Title: Re: bitcoind upstart configuration - ubuntu Post by: chill1 on September 08, 2014, 08:03:33 PM Hi I've tried to use this script and it works fine for starting the daemon on system boot, but doesn't help to restart it if process fails, although it should, as it has "respawn" stanza. I've tried numerous ways to do that and sorted a few minor issues on the way, but this is still not working for me. Any ideas how to make it restart automatically with upstart? regards Alex So I finally got things working on an Ubuntu 14.04 server. Here's what the final, working /etc/init/bitcoind.conf looks like: Code: description "bitcoind" Once you've added/updated your /etc/init/bitcoin.conf file, be sure to run the following: Code: initctl reload-configuration Basically this was just a lot of guess and check to make this finally work. Here's the important bit: Code: expect fork Essentially, 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 (http://upstart.ubuntu.com/cookbook/#expect-fork) for the specifics on this. You should be able to manually start bitcoind as a service, like this: Code: service bitcoind start Or stop it, like this: Code: service bitcoind stop If you restart your server, the bitcoind service should be started automatically. And, if the bitcoind process is killed or crashes, it will be automatically respawned. You can test that part out on your server by first finding the PID of the bitcoind process: Code: ps cax | grep bitcoind Then, kill the process manually: Code: kill -9 PID_OF_BITCOIND Then, try to get the PID of the bitcoind process again: Code: ps cax | grep bitcoind It should still be running and with a new PID. Title: Re: bitcoind upstart configuration - ubuntu Post by: zertsekel on December 01, 2014, 07:12:40 PM The only script that worked for me is the usual way - in /etc/init.d directory:
################################################################################ #! /bin/sh user="kostaz"; # peer="???"; dir="/home/${user}"; daemon="bitcoind"; pidfile="${dir}/.bitcoin/${daemon}.pid"; daemonfull="/usr/bin/bitcoind"; # args="-daemon -addnode=${peer}"; # args="-daemon"; do_start () { echo "Starting bitcoin server..." echo "start-stop-daemon --start --chuid $user --chdir $dir --pidfile $pidfile --startas $daemonfull" # start-stop-daemon --start --chuid $user --chdir $dir --pidfile $pidfile --startas $daemonfull -- $args start-stop-daemon --start --chuid $user --chdir $dir --pidfile $pidfile --startas $daemonfull } do_stop () { echo "Stopping bitcoin server..." echo "start-stop-daemon --stop --chuid $user --chdir $dir --pidfile $pidfile --startas $daemonfull" start-stop-daemon --stop --chuid $user --chdir $dir --pidfile $pidfile --startas $daemonfull } do_status () { echo "Checking status of bitcoin server..." echo "start-stop-daemon --status --chuid $user --chdir $dir --pidfile $pidfile --startas $daemonfull" start-stop-daemon --status --chuid $user --chdir $dir --pidfile $pidfile --startas $daemonfull } case "$1" in start|"") do_start ;; stop) do_stop ;; status) do_status ;; restart) do_stop sleep 10 do_start ;; *) echo "Wrong arguments" exit 3 ;; esac : ################################################################################ After copying the script to /etc/init.d/bitcoin file and making it executable (with chmod +x) you can do: $ sudo service bitcoin start $ sudo service bitcoin stop And by creating soft link to this script at /etc/rc2.d directory bitcoin server is started after the Ubuntu 14.04 boot: $ ln -s /etc/init.d/bitcoin S93bitcoin --- Kosta |