Improve bitcoind systemd service file #10529

pull Flowdalic wants to merge 1 commits into bitcoin:master from Flowdalic:systemd-service changing 1 files +15 −12
  1. Flowdalic commented at 8:57 am on June 5, 2017: contributor

    Add comment how further options can be added or existing ones modified. Use /run/${RuntimeDirectory} for PID file.

    Remove TimeoutStopSec, TimeoutStartSec, StartLimitInterval, StartLimitBurst directives as those should be set indivdually.

    Remove Group to user the bitcoin user’s default group.

    Changed Restart from ‘always’ to ‘on-failure’ (can also be overwritten individually).

  2. Improve bitcoind systemd service file
    Add comment how further options can be added or existing ones
    modified. Use /run/${RuntimeDirectory} for PID file.
    
    Remove TimeoutStopSec, TimeoutStartSec, StartLimitInterval,
    StartLimitBurst directives as those should be set indivdually.
    
    Remove Group to user the bitcoin user's default group.
    
    Changed Restart from 'always' to 'on-failure' (can also be overwritten
    individually).
    16be7ddbaa
  3. Flowdalic force-pushed on Jun 5, 2017
  4. laanwj added the label Utils and libraries on Jun 5, 2017
  5. TheBlueMatt commented at 3:18 pm on June 7, 2017: member
    It seems weird to move the datadir without the user noticing?
  6. laanwj commented at 4:01 pm on June 7, 2017: member

    It seems weird to move the datadir without the user noticing?

    /var/lib/bitcoind seems to make more sense too. Without specifying it it will move to somewhere under /home, which is not recommended for a system-wide daemon.

  7. luke-jr commented at 6:27 pm on June 7, 2017: member

    Context: bitcoind’s service scripts (at least the openrc one) has always used the bitcoin user’s default datadir. This systemd script was incompatible with this for some reason.

    At least on Gentoo systems, the bitcoin user’s home directory is itself /var/lib/bitcoin, so the datadir ends up as /var/lib/bitcoin/.bitcoin/

  8. Flowdalic commented at 7:30 pm on June 7, 2017: contributor

    Besides what @luke-jr said, my rationale was that as few things as possible should be specified in the systemd service, all bitcoind specifics should go into /etc/bitcoin/bitcoin.conf. Thus the bare minium the service file has to specify how bitcoind should be invoked is

    1. -daemon
    2. -conf=
    3. -pid=

    I’m not sure if it’s the case, but if command arguments override bitcoin.conf settings, then the user would not be able to change datadir without fiddling with the systemd service file.

    But I’m happy to re-add -datadir if it’s deemed necessary.

  9. laanwj commented at 7:59 am on June 8, 2017: member
    What about TimeoutStartSec? #10531 increases it to 120s, this removes it completely. I’m not sure what you mean with ‘should be set individually’ in the OP. What is the default?
  10. Flowdalic commented at 10:09 am on June 8, 2017: contributor

    What about TimeoutStartSec? #10531 increases it to 120s, this removes it completely.

    The default is 90s, which is sufficient for most bitcoind setups I know. If a users has a particular cause for a different value (like a very slow system), then he can simply to override it, using the systemctl edit bitocind.service approach mentioned in the added comment block. That is what I meant with “should be set individually”. The idea is that systemd’s default are reasonable for most cases, and if it doesn’t work for someone, then systemd allows you override the defaults. I could be wrong, but I don’t see a reason why bitcoind should always need TimeoutStartSec set to 120s, instead of the default value (90s).

  11. laanwj commented at 10:44 am on June 8, 2017: member
    What does this timeout measure in the first place? Until RPC becomes reachable? Or until it becomes usable?
  12. Flowdalic commented at 11:24 am on June 8, 2017: contributor

    What does this timeout measure in the first place?

    Good question. I can’t find anything in the documentation. And a short look at the source also didn’t help.

    Until RPC becomes reachable? Or until it becomes usable?

    I doubt that, since systemd has no specific knowledge of the service. I’d guess that for ‘forking’ type services like bitcoind, it’s the time the initial process needs to terminate.

  13. laanwj commented at 10:13 am on June 25, 2017: member
    So I’m not clear what to do here. This isn’t gathering any (ut)ACKs and neither is #10531. Who is using these files and has an opinion about them?
  14. laanwj commented at 11:56 am on July 25, 2017: member
    This seems inactive, closing for now
  15. laanwj closed this on Jul 25, 2017

  16. Flowdalic commented at 12:11 pm on July 25, 2017: contributor

    What a pity. Needless to say that I believe this PR was an improvement over what is currently in the repo. ;)

    The usual consumers are people who package bitcoind for their Linux distribution. For example, the Gentoo bitcoin overlay (which I’m involved with) and the Gentoo in-tree ebuilds would probably switch to the canonical bitcoind systemd files if they where in a good shape.

  17. laanwj commented at 12:26 pm on July 25, 2017: member

    After discussion on IRC I’m reopening this.

    (Apparently the current state is completely broken, so if there can’t be agreement on how to improve it, it’d be better to remove it completely.)

  18. laanwj reopened this on Jul 25, 2017

  19. ryanofsky commented at 2:37 pm on July 25, 2017: member

    What does this timeout measure in the first place? Until RPC becomes reachable? Or until it becomes usable?

    This is a forking service so timeout is just checking time until original foreground process exits successfully.

  20. in contrib/init/bitcoind.service:15 in 16be7ddbaa
    11-Description=Bitcoin's distributed currency daemon
    12+Description=Bitcoin daemon
    13 After=network.target
    14 
    15 [Service]
    16+ExecStart=/usr/bin/bitcoind -daemon -conf=/etc/bitcoin/bitcoin.conf -pid=/run/bitcoind/bitcoind.pid
    


    ryanofsky commented at 2:40 pm on July 25, 2017:
    Probably should use /etc/bitcoind to be consistent with /run/bitcoind or /run/bitcoin to be consistent with /etc/bitcoin

    Flowdalic commented at 6:05 pm on July 26, 2017:
    I’ve no strong feelings towards any of those options, besides that keeping /etc/bitcoin/ would make it a bit easier for the gentoo ebuilds, as that is what they currently use.

    ryanofsky commented at 7:11 pm on July 26, 2017:
    Yeah actually I take back the suggestion. Seems fine to stick with /etc/bitcoin since the config there could potentially could be shared with different bitcoin tools. And /var/bitcoind at least keeps consistency with the binary and service names.

    luke-jr commented at 2:45 am on July 27, 2017:
    Yeah, at least hypothetically, bitcoin-cli would ideally be able to use it too.

    erols commented at 9:44 pm on November 27, 2017:
    If I’m setting up systemd do I need to create the bitcoin user and group myself?
  21. ryanofsky commented at 2:44 pm on July 25, 2017: member
    utACK 16be7ddbaa7cb0de99c84fac2d33d713e03301cf. This does seem like an improvement and it is good to move configuration out of the service file. If overriding datadir is desirable, seems like that could happen in the bitcoin.conf file which the service file is referencing.
  22. in contrib/init/bitcoind.service:15 in fac2c22ce1 outdated
    11@@ -12,7 +12,7 @@ Description=Bitcoin daemon
    12 After=network.target
    13 
    14 [Service]
    15-ExecStart=/usr/bin/bitcoind -daemon -conf=/etc/bitcoin/bitcoin.conf -pid=/run/bitcoind/bitcoind.pid
    16+ExecStart=/usr/bin/bitcoind -daemon -conf=/etc/bitcoin/bitcoin.conf -pid=/run/bitcoind/bitcoind.pid -printtoconsole -logtimestamps=0
    


    laanwj commented at 10:29 am on August 28, 2017:
    Don’t combine -daemon and -printtoconsole - stdout will have nowhere to go after daemonization.

    Flowdalic commented at 12:13 pm on August 29, 2017:
    The idea was to let systemd handle bitcoind’s log output. At first using -daemon and -printtoconsole appeared to do the trick, but on a second look it sees that the log output stops after bitcoind demonized (possibly after the fork()?)

    ryanofsky commented at 2:30 pm on August 29, 2017:

    The idea was to let systemd handle bitcoind’s log output. At first using -daemon and -printtoconsole appeared to do the trick, but on a second look it sees that the log output stops after bitcoind demonized (possibly after the fork()?)

    You could make work this by removing -daemon and -pid options, removing PIDFile setting, and changing Type setting from forking to simple. Personally, I would just want to use bitcoin logging, though, so logs can be more easily deleted if they contain private information, or if I enable verbose debugging and want to reclaim space. I would also leans towards using bitcoin logging here just to avoid adding unnecessary config overrides and differences between the way bitcoin functions inside and outside of systemd.


    Flowdalic commented at 8:49 pm on August 30, 2017:
    I see your rationale, but on the other hand there are also good reasons to let systemd handle the log output of bitcoind. But since the this change was broken anyways (and since we can decide what’s best later on,) I’ve reverted the commit with the hope that it would make it easier to get this PR merged.
  23. laanwj commented at 12:52 pm on October 2, 2017: member
    Please squash before merging.
  24. Flowdalic force-pushed on Oct 2, 2017
  25. Flowdalic commented at 1:12 pm on October 2, 2017: contributor
    Squashed.
  26. ryanofsky commented at 6:32 pm on October 12, 2017: member
    utACK 16be7ddbaa7cb0de99c84fac2d33d713e03301cf again (the later commit fac2c22ce176529893bb41a1856e2854d1db5e20 which had the -printtoconsole stuff is now gone).
  27. laanwj merged this on Nov 9, 2017
  28. laanwj closed this on Nov 9, 2017

  29. laanwj referenced this in commit 331352f99f on Nov 9, 2017
  30. Flowdalic deleted the branch on Nov 9, 2017
  31. PastaPastaPasta referenced this in commit 9905f3d822 on Dec 22, 2019
  32. PastaPastaPasta referenced this in commit b34f4d1922 on Jan 2, 2020
  33. PastaPastaPasta referenced this in commit bc7e313661 on Jan 4, 2020
  34. PastaPastaPasta referenced this in commit d6b2084940 on Jan 12, 2020
  35. PastaPastaPasta referenced this in commit dbfe651d29 on Jan 12, 2020
  36. PastaPastaPasta referenced this in commit 5e47c1abfd on Jan 12, 2020
  37. PastaPastaPasta referenced this in commit bc7ffebe11 on Jan 12, 2020
  38. PastaPastaPasta referenced this in commit 878224ae50 on Jan 12, 2020
  39. PastaPastaPasta referenced this in commit 2e3debd87d on Jan 12, 2020
  40. PastaPastaPasta referenced this in commit e9bc03a32e on Jan 16, 2020
  41. PastaPastaPasta referenced this in commit 9c914a1c14 on Jan 22, 2020
  42. PastaPastaPasta referenced this in commit 6e71870857 on Jan 29, 2020
  43. PastaPastaPasta referenced this in commit 98725c5917 on Jan 29, 2020
  44. MarcoFalke locked this on Sep 8, 2021

github-metadata-mirror

This is a metadata mirror of the GitHub repository bitcoin/bitcoin. This site is not affiliated with GitHub. Content is generated from a GitHub metadata backup.
generated: 2024-12-19 06:12 UTC

This site is hosted by @0xB10C
More mirrored repositories can be found on mirror.b10c.me