Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bitcoind as system background service #4124

Closed
laanwj opened this issue May 4, 2014 · 20 comments
Closed

Bitcoind as system background service #4124

laanwj opened this issue May 4, 2014 · 20 comments
Labels

Comments

@laanwj
Copy link
Member

laanwj commented May 4, 2014

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).

@laanwj laanwj added the Feature label May 4, 2014
@sipa
Copy link
Member

sipa commented May 5, 2014

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).

@laanwj
Copy link
Member Author

laanwj commented May 6, 2014

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

@laanwj
Copy link
Member Author

laanwj commented May 6, 2014

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

@itoffshore
Copy link
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

@gmaxwell
Copy link
Contributor

gmaxwell commented May 9, 2014

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?

@itoffshore
Copy link
Contributor

do you consider /dev/urandom strong enough ?

@gmaxwell
Copy link
Contributor

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

@itoffshore
Copy link
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

@gmaxwell
Copy link
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. :)

@itoffshore
Copy link
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.

@laanwj
Copy link
Member Author

laanwj commented May 29, 2014

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...).

@dugongsoftware
Copy link

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

@itoffshore
Copy link
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).

@msgilligan
Copy link

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

msgilligan added a commit to msgilligan/omnicore that referenced this issue Sep 15, 2014
Back-ported some files from BitCoin core (approved) PR’s with some
additions for Master Core.

See:
bitcoin#4124
bitcoin#4611
@msgilligan
Copy link

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)

@itoffshore
Copy link
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

@doll1
Copy link

doll1 commented Sep 18, 2014

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

@laanwj
Copy link
Member Author

laanwj commented Oct 27, 2015

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

@laanwj laanwj closed this as completed Oct 27, 2015
@rebroad
Copy link
Contributor

rebroad commented Sep 9, 2016

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

@laanwj
Copy link
Member Author

laanwj commented Sep 9, 2016

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

@bitcoin bitcoin locked as resolved and limited conversation to collaborators Sep 8, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

8 participants