bitcoin-core / packaging

Distribution-specific packaging for Bitcoin Core
41 stars 43 forks source link

Run as a service #62

Open gunar opened 3 years ago

gunar commented 3 years ago

Hi,

How can I set up the snap packge to start bitcoind automatically? I'm having trouble running bitcoin-core.daemon as a service on CentOS. It seems snap (i.e. SELinux) won't let systemd read the binary file bitcoin-daemon that lives inside the snap container. Please find logs and service file below. Any help is greatly appreciated.

Also, I've just learned there's a thing called a "snap services" (docs). Perhaps that'd be the best way to move forward? In that case, perhaps we should consider adding a service configuration to this repo?

Thanks in advance.

journalctl -xe ``` setroubleshoot[3079]: AnalyzeThread.run(): Set alarm timeout to 10 setroubleshoot[3079]: AnalyzeThread.run(): Cancel pending alarm setroubleshoot[3079]: failed to retrieve rpm info for /var/lib/snapd/snap/bin/bitcoin-core.daemon setroubleshoot[3079]: SELinux is preventing /usr/lib/systemd/systemd from read access on the lnk_file /var/lib/snapd/snap> ***** Plugin catchall (100. confidence) suggests ************************** If you believe that systemd should be allowed read access on the bitcoin-core.daemon lnk_file by de> Then you should report this as a bug. You can generate a local policy module to allow this access. Do allow this access for now by executing: # ausearch -c '(e.daemon)' --raw | audit2allow -M my-edaemon # semodule -X 300 -i my-edaemon.pp ```
/etc/systemd/system/bitcoind.service ``` [Unit] Description=Bitcoin daemon After=network.target [Service] ExecStart=/var/lib/snapd/snap/bin/bitcoin-core.daemon -daemon -pid=/home/bitcoin/.bitcoin/bitcoind.pid -conf=/home/bitcoin/.bitcoin/bitcoin.conf -datadir=/home/bitcoin/.bitcoin # Make sure the config directory is readable by the service user ExecStartPre=+/bin/chgrp bitcoin /home/bitcoin/.bitcoin # Process management #################### Type=forking PIDFile=/home/bitcoin/.bitcoin/bitcoind.pid Restart=on-failure TimeoutStopSec=600 # Directory creation and permissions #################################### # Run as bitcoin:bitcoin User=bitcoin Group=bitcoin [Install] WantedBy=multi-user.target ```
BadCo-NZ commented 2 years ago

Did you get this figured out? I am currently running into this problem, running the snap as a service.

twkonefal commented 2 years ago

I think the snaps aren't made correctly, but this is just a guess: Snap Service Management Docs

I expected a "snap services" output showing bitcoin-core, but it's not there in spite of "snap list" showing bitcoin-core as installed. To me this means there is no service support with snaps. I hope I'm wrong :)

242617 commented 5 months ago

I have the same question. It's weird that no answer was given for such popular topic.

BadCo-NZ commented 5 months ago

I have the same question. It's weird that no answer was given for such popular topic.

I ended up just using Umbrel in a VM, which also has built in Tor.

gunar commented 5 months ago

Did you get this figured out?

Nope, I've moved to https://github.com/fort-nix/nix-bitcoin

achow101 commented 5 months ago

I don't think any of the people who work on Bitcoin Core use snaps or are particularly familiar with them. While we provide a snap as a courtesy, they are not particularly well maintained and doing anything more advanced than simply making the binaries available to be run is unlikely to happen. #225 is an attempt at making a snap service, but it may not work as I also do not use snaps nor am I well versed in how they work.