Skip to content

Run as a service #62

Open
Open

Description

@gunar

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

Activity

  1. BadCo-NZ commented on May 26, 2022

    @BadCo-NZ

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

  2. twkonefal commented on Aug 14, 2022

    @twkonefal

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

  3. 242617 commented on Apr 18, 2024

    @242617

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

  4. BadCo-NZ commented on Apr 18, 2024

    @BadCo-NZ

    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.

  5. gunar commented on Apr 18, 2024

    @gunar
    Author

    Did you get this figured out?

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

  6. achow101 commented on Apr 18, 2024

    @achow101
    Member

    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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions