Merge #12062: Increment MIT Licence copyright header year on files modified in 2017
[bitcoinplatinum.git] / doc / init.md
blob75f9013f296b9ee0ffc79e19fdf43819eab5007b
1 Sample init scripts and service configuration for bitcoind
2 ==========================================================
4 Sample scripts and configuration files for systemd, Upstart and OpenRC
5 can be found in the contrib/init folder.
7     contrib/init/bitcoind.service:    systemd service unit configuration
8     contrib/init/bitcoind.openrc:     OpenRC compatible SysV style init script
9     contrib/init/bitcoind.openrcconf: OpenRC conf.d file
10     contrib/init/bitcoind.conf:       Upstart service configuration file
11     contrib/init/bitcoind.init:       CentOS compatible SysV style init script
13 Service User
14 ---------------------------------
16 All three Linux startup configurations assume the existence of a "bitcoin" user
17 and group.  They must be created before attempting to use these scripts.
18 The OS X configuration assumes bitcoind will be set up for the current user.
20 Configuration
21 ---------------------------------
23 At a bare minimum, bitcoind requires that the rpcpassword setting be set
24 when running as a daemon.  If the configuration file does not exist or this
25 setting is not set, bitcoind will shutdown promptly after startup.
27 This password does not have to be remembered or typed as it is mostly used
28 as a fixed token that bitcoind and client programs read from the configuration
29 file, however it is recommended that a strong and secure password be used
30 as this password is security critical to securing the wallet should the
31 wallet be enabled.
33 If bitcoind is run with the "-server" flag (set by default), and no rpcpassword is set,
34 it will use a special cookie file for authentication. The cookie is generated with random
35 content when the daemon starts, and deleted when it exits. Read access to this file
36 controls who can access it through RPC.
38 By default the cookie is stored in the data directory, but it's location can be overridden
39 with the option '-rpccookiefile'.
41 This allows for running bitcoind without having to do any manual configuration.
43 `conf`, `pid`, and `wallet` accept relative paths which are interpreted as
44 relative to the data directory. `wallet` *only* supports relative paths.
46 For an example configuration file that describes the configuration settings,
47 see `contrib/debian/examples/bitcoin.conf`.
49 Paths
50 ---------------------------------
52 ### Linux
54 All three configurations assume several paths that might need to be adjusted.
56 Binary:              `/usr/bin/bitcoind`  
57 Configuration file:  `/etc/bitcoin/bitcoin.conf`  
58 Data directory:      `/var/lib/bitcoind`  
59 PID file:            `/var/run/bitcoind/bitcoind.pid` (OpenRC and Upstart) or `/var/lib/bitcoind/bitcoind.pid` (systemd)  
60 Lock file:           `/var/lock/subsys/bitcoind` (CentOS)  
62 The configuration file, PID directory (if applicable) and data directory
63 should all be owned by the bitcoin user and group.  It is advised for security
64 reasons to make the configuration file and data directory only readable by the
65 bitcoin user and group.  Access to bitcoin-cli and other bitcoind rpc clients
66 can then be controlled by group membership.
68 ### Mac OS X
70 Binary:              `/usr/local/bin/bitcoind`  
71 Configuration file:  `~/Library/Application Support/Bitcoin/bitcoin.conf`  
72 Data directory:      `~/Library/Application Support/Bitcoin`  
73 Lock file:           `~/Library/Application Support/Bitcoin/.lock`  
75 Installing Service Configuration
76 -----------------------------------
78 ### systemd
80 Installing this .service file consists of just copying it to
81 /usr/lib/systemd/system directory, followed by the command
82 `systemctl daemon-reload` in order to update running systemd configuration.
84 To test, run `systemctl start bitcoind` and to enable for system startup run
85 `systemctl enable bitcoind`
87 ### OpenRC
89 Rename bitcoind.openrc to bitcoind and drop it in /etc/init.d.  Double
90 check ownership and permissions and make it executable.  Test it with
91 `/etc/init.d/bitcoind start` and configure it to run on startup with
92 `rc-update add bitcoind`
94 ### Upstart (for Debian/Ubuntu based distributions)
96 Drop bitcoind.conf in /etc/init.  Test by running `service bitcoind start`
97 it will automatically start on reboot.
99 NOTE: This script is incompatible with CentOS 5 and Amazon Linux 2014 as they
100 use old versions of Upstart and do not supply the start-stop-daemon utility.
102 ### CentOS
104 Copy bitcoind.init to /etc/init.d/bitcoind. Test by running `service bitcoind start`.
106 Using this script, you can adjust the path and flags to the bitcoind program by
107 setting the BITCOIND and FLAGS environment variables in the file
108 /etc/sysconfig/bitcoind. You can also use the DAEMONOPTS environment variable here.
110 ### Mac OS X
112 Copy org.bitcoin.bitcoind.plist into ~/Library/LaunchAgents. Load the launch agent by
113 running `launchctl load ~/Library/LaunchAgents/org.bitcoin.bitcoind.plist`.
115 This Launch Agent will cause bitcoind to start whenever the user logs in.
117 NOTE: This approach is intended for those wanting to run bitcoind as the current user.
118 You will need to modify org.bitcoin.bitcoind.plist if you intend to use it as a
119 Launch Daemon with a dedicated bitcoin user.
121 Auto-respawn
122 -----------------------------------
124 Auto respawning is currently only configured for Upstart and systemd.
125 Reasonable defaults have been chosen but YMMV.