1
  1. When running bitcoind from a systemd service, as in https://github.com/bitcoin/bitcoin/blob/master/contrib/init/bitcoind.service, what is the role of the -daemon flag?

Basically I'm asking what does -daemon do in a situation where bitcoind is run as service, and not as a wallet. And what happens if -daemon is not used -> in a systemd service file.

  1. If one sets daemon=1 in bitcoin.conf, is it redundant to also use the -daemon flag when starting
1

When running bitcoind from a systemd service, as in https://github.com/bitcoin/bitcoin/blob/master/contrib/init/bitcoind.service, what is the role of the -daemon flag?

-daemon starts bitcoind in the background as a daemon. So if you run bitcoind -daemon in the terminal, the program will exit immediately but bitcoind is still running in the background. Without -daemon, you will see that bitcoind appears to hang in the terminal, but that just means it is running. If you stop the command, then bitcoind will stop as well.

If one sets daemon=1 in bitcoin.conf, is it redundant to also use the -daemon flag when starting

Yes. This applies for all command line options.

| improve this answer | |
  • Yes, I see that the terminal seems 'occupied' or 'hanging' when the daemon setting is turned off. But my question was not about starting the daemon in terminal, but in a systemd service. In this case what is the consequence of running with the daemon setting turned on, or going instead Type=simple and no daemon does the job correctly also? – user2066480 Apr 18 '18 at 21:48
  • As I explained in your other question about this, you cannot use Type=simple without -daemon. Systemd will not work with that. – Andrew Chow Apr 18 '18 at 22:18
  • In the other question about forking vs simple, you made a case against using Type=simple together with daemon=1. In my comment above I was asking for Type=simple together with daemon=0. – user2066480 Apr 18 '18 at 22:37
  • I see. There is no difference between using Type=simple and daemon=0 and using Type=forking and daemon=1. – Andrew Chow Apr 18 '18 at 23:01
  • From my experience Type=simple and daemon=1 in btc conf file, makes daemon shotdown just after start with systemctl start – Pawel Cioch Dec 20 '18 at 23:12
1

I think understanding the hierarchy of how software works would be helpful here. You're interacting with the software, Bitcoin Core. While you're experiencing either a GUI wallet and network stats or interacting with the bitcoin-cli, your OS is experiencing bitcoind, the bitcoin daemon. It is--in the scope of this scenario--the fundamental piece of your bitcoin node or wallet.

Wikipedia introduces Daemons nicely:

a daemon (/ˈdiːmən/ or /ˈdeɪmən/)[1] is a computer program that runs as a background process, rather than being under the direct control of an interactive user

Spooky. In Unix systems specifically, it is a daemon if

the process is started from the command line or from a startup script such as an init script

The init script in this case is the bitcoin.conf file. If it initiates the daemon, it is doing it's thing running in the background. All the core processes that are required to run the underlying code and for a GUI and command line to be used on top of that are active, silently.

Any interaction that you have with the software requires the daemon to be running. If it's not already, it will start it. Once running, you can change the bitcoin.conf file or variables dynamically through the command line as you see fit during your session.

Then when you're done, whatever state the bitcoin.conf file is in when the computer or daemon begin will determine it's behavior.

If you want bitcoin running in the background always, ensure that the config file runs the daemon on startup or that you start it yourself if it's not running. It is redundant to do both.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.