Bitcoind as system background service #4124

issue laanwj opened this issue on May 4, 2014
  1. laanwj commented at 10:22 AM on May 4, 2014: member

    When using bitcoind as a wallet-less full node, it would be useful to be able to run it as a system service, so that it starts automatically at startup and can be controlled though the OS's normal service start and stop functionality.

    For the Debian/Ubuntu side of things see hippich and fungus' posts here: https://bitcointalk.org/?topic=965.0 . It'd make most sense to integrate this into the PPA. There are two different systems in use here: old-style sysv init scripts, and upstart.

    For Windows/OSX I'm not sure what is necessary. At least we'd need new installer packages, separate from the normal "Bitcoin Core Wallet" which provide a node and nothing more.

    The installer would also need to create user credentials to run under.

    Edit: for the service install, this would also imply moving the configuration to a system-wide instead of user location, for example /etc/bitcoin.conf as well as default the data directory to a system-scope location (probably /var/lib/bitcoin).

  2. laanwj added the label Feature on May 4, 2014
  3. sipa commented at 10:02 PM on May 5, 2014: member

    Yes, we need this.

    It would also mean the blockchain database can become shared and system-wide, and be stored in /var/lib/bitcoin or something, instead of in home directories (which seems frowned upon, for such amounts of data).

  4. laanwj commented at 7:30 AM on May 6, 2014: member

    Yes, sounds like a good plan. As we don't have to worry about the wallet here, everything can be public and shared.

  5. laanwj commented at 8:43 AM on May 6, 2014: member

    @drak You do realize that calling something 'trivial' is the same as volunteering to implement it?

  6. itoffshore commented at 11:20 PM on May 9, 2014: contributor

    I've just introduced this to Alpine Linux. The bitcoin daemon runs under /var/lib/bitcoin as bitcoin:bitcoin using /etc/bitcoin.conf for configuration. The post install script generates a random user / pass / port for a new installation. The init script also enforces sensible permissions.

    Via LXC 1.00+ it is possible to run an unprivileged Alpine container on any Linux (size 5mb)

    Same is possible for namecoin

  7. gmaxwell commented at 11:25 PM on May 9, 2014: contributor

    Hopefully you did not do what the debian package did at one point and use a non-cryptographic PRNG to pick those keys, making it trivial to guess the rpc credentials?

  8. itoffshore commented at 12:05 AM on May 10, 2014: contributor

    do you consider /dev/urandom strong enough ?

  9. gmaxwell commented at 12:23 AM on May 10, 2014: contributor

    Sure, but its how you use it that counts. Link me to the code and I'll review it.

  10. itoffshore commented at 12:39 AM on May 10, 2014: contributor

    It's the 2nd from last addition at http://lists.alpinelinux.org/alpine-devel/3710.html

    User is 32 char & Pass is 64 char

  11. gmaxwell commented at 1:28 AM on May 10, 2014: contributor

    @itoffshore Cool. Characters which need to be escaped in URLs break some applications, I'd recommend leaving out the symbols. The ones Bitcoin itself generates are just a base58 encoded 256-bit value. (I believe I've seen % and & both cause problems, ! is sometimes annoying if specifying the strings on the command line). Looks fine generally, the lack of error handling (e.g. /dev/urandom couldn't be opened, or something doesn't support the -c extension to head) might be concerning but bitcoin won't let you run with a too short rpcpassword. Sorry for the diversion. :)

  12. itoffshore commented at 1:55 AM on May 10, 2014: contributor

    /dev/urandom doesn't block (/dev/random does block if there is not enough entropy) - as Alpine uses Busybox the command should work everywhere.

  13. laanwj commented at 8:55 PM on May 29, 2014: member

    The system service would concern a wallet-less build, so generating a safe rpcuser/pass is not of critical importance (and given that RPC listens on localhost only...).

  14. dugongsoftware commented at 2:18 AM on June 22, 2014: none

    @drak have you got it working? I've tried registering as a windows service via sc. exe create but no luck.

  15. itoffshore commented at 4:02 PM on June 25, 2014: contributor

    Alpine Linux has packages now for Bitcoin / Namecoin with both running as a service as Bitcoin / Namecoin user:groups. There are templates in LXC for Alpine (a running Alpine container is 5 meg in size) so it is simple to run Bitcoin on any Linux (or as a virtualbox service in Windows).

  16. msgilligan commented at 2:03 AM on September 15, 2014: none

    There is also a PR with Upstart and OpenRC support #4611

  17. msgilligan referenced this in commit 005f913982 on Sep 15, 2014
  18. msgilligan commented at 12:44 AM on September 17, 2014: none

    This (and PR #4611) is some nice work. Is there any (official) effort to make an Ubuntu (or other distro) package that includes it?

    (Edit: I've seen the existing PPA repository and the current bitcoin package does not include any init scripts)

  19. itoffshore commented at 1:25 AM on September 17, 2014: contributor

    On any Linux distribution install LXC (Ubuntu / Debian / Redhat / Archlinux / OpenSUSE have packages) & create an Alpine Linux container (this is 5 meg in size).

    Log in to the container (user = root & password is empty) & run:

    apk add bitcoin
    rc-update add bitcoin default
    rc-service bitcoin start
    

    & bitcoin will run as user bitcoin. There is also a package for namecoin in Alpine.

    For extra security & complete isolation run an unprivileged container.

    Ubuntu docs for LXC

  20. doll1 commented at 7:30 AM on September 18, 2014: none

    Nice work. Would love to see a package for Litecoin too.

  21. laanwj commented at 11:03 AM on October 27, 2015: member

    This is sufficiently done now (doc/init.md), thanks everyone, closing the issue

  22. laanwj closed this on Oct 27, 2015

  23. rebroad commented at 5:36 AM on September 9, 2016: contributor

    What about running it as a service on Microsoft Windows? This doesn't seem to have been addressed.

  24. laanwj commented at 8:02 AM on September 9, 2016: member

    We don't have any active windows developers, so none of us will do that. But feel free to write a guide on that.

  25. MarcoFalke locked this on Sep 8, 2021

github-metadata-mirror

This is a metadata mirror of the GitHub repository bitcoin/bitcoin. This site is not affiliated with GitHub. Content is generated from a GitHub metadata backup.
generated: 2026-04-13 15:15 UTC

This site is hosted by @0xB10C
More mirrored repositories can be found on mirror.b10c.me