packaging icon indicating copy to clipboard operation
packaging copied to clipboard

Run as a service

Open gunar opened this issue 4 years ago • 6 comments

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

gunar avatar Feb 02 '21 11:02 gunar

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

BadCo-NZ avatar May 26 '22 03:05 BadCo-NZ

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

twkonefal avatar Aug 14 '22 04:08 twkonefal

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

242617 avatar Apr 18 '24 17:04 242617

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.

BadCo-NZ avatar Apr 18 '24 19:04 BadCo-NZ

Did you get this figured out?

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

gunar avatar Apr 18 '24 19:04 gunar

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.

achow101 avatar Apr 18 '24 21:04 achow101