Skip to content

Run as a service #62

@gunar

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

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