@cryptotaxi247 / kubo / commits / 77f2b04cc

misc/README.md: import readme from ipfs/website repo

Authors: @lgierth @CameronNemo @jessicaschilling URL: https://github.com/ipfs/website/blob/master/static/docs/examples/init/README.md License: MIT

@RubenKelevra committed Jun 13, 2020 at 07:54 UTC 77f2b04ccef8511731c7ec55fe89fc4de56b00fb
1 file changed +249
misc/README.md new
+249
@@ -0,0 +1,249 @@
1 +## init system integration
2 +
3 +go-ipfs can be started by your operating system's native init system.
4 +
5 +- [systemd](#systemd)
6 +- [LSB init script](#initd)
7 +- [Upstart/startup job](#upstart)
8 +- [launchd](#launchd)
9 +
10 +### systemd
11 +
12 +For `systemd`, the best approach is to run the daemon in a user session. Here is a sample service file:
13 +
14 +```systemd
15 +[Unit]
16 +Description=IPFS daemon
17 +
18 +[Service]
19 +# Environment="IPFS_PATH=/data/ipfs" # optional path to ipfs init directory if not default ($HOME/.ipfs)
20 +ExecStart=/usr/bin/ipfs daemon
21 +Restart=on-failure
22 +
23 +[Install]
24 +WantedBy=default.target
25 +```
26 +
27 +To run this in your user session, save it as `~/.config/systemd/user/ipfs.service` (creating directories as necessary). Once you run `ipfs init` to create your IPFS settings, you can control the daemon using the following commands:
28 +
29 +* `systemctl --user start ipfs` - start the daemon
30 +* `systemctl --user stop ipfs` - stop the daemon
31 +* `systemctl --user status ipfs` - get status of the daemon
32 +* `systemctl --user enable ipfs` - enable starting the daemon at boot
33 +* `systemctl --user disable ipfs` - disable starting the daemon at boot
34 +
35 +*Note:* If you want this `--user` service to run at system boot, you must [`enable-linger`](http://www.freedesktop.org/software/systemd/man/loginctl.html) on the account that runs the service:
36 +
37 +```
38 +# loginctl enable-linger [user]
39 +```
40 +Read more about `--user` services here: [wiki.archlinux.org:Systemd ](https://wiki.archlinux.org/index.php/Systemd/User#Automatic_start-up_of_systemd_user_instances)
41 +
42 +### initd
43 +
44 +- Here is a full-featured sample service file: https://github.com/dylanPowers/ipfs-linux-service/blob/master/init.d/ipfs
45 +- Use `service` or your distribution's equivalent to control the service.
46 +
47 +## upstart
48 +
49 +- And below is a very basic sample upstart job. **Note the username jbenet**.
50 +
51 +```
52 +cat /etc/init/ipfs.conf
53 +```
54 +```
55 +description "ipfs: interplanetary filesystem"
56 +
57 +start on (local-filesystems and net-device-up IFACE!=lo)
58 +stop on runlevel [!2345]
59 +
60 +limit nofile 524288 1048576
61 +limit nproc 524288 1048576
62 +setuid jbenet
63 +chdir /home/jbenet
64 +respawn
65 +exec ipfs daemon
66 +```
67 +
68 +Another version is available here:
69 +
70 +```sh
71 +ipfs cat /ipfs/QmbYCwVeA23vz6mzAiVQhJNa2JSiRH4ebef1v2e5EkDEZS/ipfs.conf >/etc/init/ipfs.conf
72 +```
73 +
74 +For both, edit to replace occurrences of `jbenet` with whatever user you want it to run as:
75 +
76 +```sh
77 +sed -i s/jbenet/<chosen-username>/ /etc/init/ipfs.conf
78 +```
79 +
80 +Once you run `ipfs init` to create your IPFS settings, you can control the daemon using the `init.d` commands:
81 +
82 +```sh
83 +sudo service ipfs start
84 +sudo service ipfs stop
85 +sudo service ipfs restart
86 +...
87 +```
88 +
89 +## launchd
90 +
91 +Similar to `systemd`, on macOS you can run `go-ipfs` via a user LaunchAgent.
92 +
93 +- Create `~/Library/LaunchAgents/io.ipfs.go-ipfs.plist`:
94 +
95 +```xml
96 +<?xml version="1.0" encoding="UTF-8"?>
97 +<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
98 +<plist version="1.0">
99 +<dict>
100 + <key>KeepAlive</key>
101 + <true/>
102 + <key>Label</key>
103 + <string>io.ipfs.go-ipfs</string>
104 + <key>ProcessType</key>
105 + <string>Background</string>
106 + <key>ProgramArguments</key>
107 + <array>
108 + <string>/bin/sh</string>
109 + <string>-c</string>
110 + <string>~/go/bin/ipfs daemon</string>
111 + </array>
112 + <key>RunAtLoad</key>
113 + <true/>
114 +</dict>
115 +</plist>
116 +```
117 +The reason for running `ipfs` under a shell is to avoid needing to hard-code the user's home directory in the job.
118 +
119 +- To start the job, run `launchctl load ~/Library/LaunchAgents/io.ipfs.go-ipfs.plist`
120 +
121 +Notes:
122 +
123 +- To check that the job is running, run `launchctl list | grep ipfs`.
124 +- IPFS should now start whenever you log in (and exit when you log out).
125 +- [LaunchControl](http://www.soma-zone.com/LaunchControl/) is a GUI tool which simplifies management of LaunchAgents.## init system integration
126 +
127 +go-ipfs can be started by your operating system's native init system.
128 +
129 +- [systemd](#systemd)
130 +- [LSB init script](#initd)
131 +- [Upstart/startup job](#upstart)
132 +- [launchd](#launchd)
133 +
134 +### systemd
135 +
136 +For `systemd`, the best approach is to run the daemon in a user session. Here is a sample service file:
137 +
138 +```systemd
139 +[Unit]
140 +Description=IPFS daemon
141 +
142 +[Service]
143 +# Environment="IPFS_PATH=/data/ipfs" # optional path to ipfs init directory if not default ($HOME/.ipfs)
144 +ExecStart=/usr/bin/ipfs daemon
145 +Restart=on-failure
146 +
147 +[Install]
148 +WantedBy=default.target
149 +```
150 +
151 +To run this in your user session, save it as `~/.config/systemd/user/ipfs.service` (creating directories as necessary). Once you run `ipfs init` to create your IPFS settings, you can control the daemon using the following commands:
152 +
153 +* `systemctl --user start ipfs` - start the daemon
154 +* `systemctl --user stop ipfs` - stop the daemon
155 +* `systemctl --user status ipfs` - get status of the daemon
156 +* `systemctl --user enable ipfs` - enable starting the daemon at boot
157 +* `systemctl --user disable ipfs` - disable starting the daemon at boot
158 +
159 +*Note:* If you want this `--user` service to run at system boot, you must [`enable-linger`](http://www.freedesktop.org/software/systemd/man/loginctl.html) on the account that runs the service:
160 +
161 +```
162 +# loginctl enable-linger [user]
163 +```
164 +Read more about `--user` services here: [wiki.archlinux.org:Systemd ](https://wiki.archlinux.org/index.php/Systemd/User#Automatic_start-up_of_systemd_user_instances)
165 +
166 +### initd
167 +
168 +- Here is a full-featured sample service file: https://github.com/dylanPowers/ipfs-linux-service/blob/master/init.d/ipfs
169 +- Use `service` or your distribution's equivalent to control the service.
170 +
171 +## upstart
172 +
173 +- And below is a very basic sample upstart job. **Note the username jbenet**.
174 +
175 +```
176 +cat /etc/init/ipfs.conf
177 +```
178 +```
179 +description "ipfs: interplanetary filesystem"
180 +
181 +start on (local-filesystems and net-device-up IFACE!=lo)
182 +stop on runlevel [!2345]
183 +
184 +limit nofile 524288 1048576
185 +limit nproc 524288 1048576
186 +setuid jbenet
187 +chdir /home/jbenet
188 +respawn
189 +exec ipfs daemon
190 +```
191 +
192 +Another version is available here:
193 +
194 +```sh
195 +ipfs cat /ipfs/QmbYCwVeA23vz6mzAiVQhJNa2JSiRH4ebef1v2e5EkDEZS/ipfs.conf >/etc/init/ipfs.conf
196 +```
197 +
198 +For both, edit to replace occurrences of `jbenet` with whatever user you want it to run as:
199 +
200 +```sh
201 +sed -i s/jbenet/<chosen-username>/ /etc/init/ipfs.conf
202 +```
203 +
204 +Once you run `ipfs init` to create your IPFS settings, you can control the daemon using the `init.d` commands:
205 +
206 +```sh
207 +sudo service ipfs start
208 +sudo service ipfs stop
209 +sudo service ipfs restart
210 +...
211 +```
212 +
213 +## launchd
214 +
215 +Similar to `systemd`, on macOS you can run `go-ipfs` via a user LaunchAgent.
216 +
217 +- Create `~/Library/LaunchAgents/io.ipfs.go-ipfs.plist`:
218 +
219 +```xml
220 +<?xml version="1.0" encoding="UTF-8"?>
221 +<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
222 +<plist version="1.0">
223 +<dict>
224 + <key>KeepAlive</key>
225 + <true/>
226 + <key>Label</key>
227 + <string>io.ipfs.go-ipfs</string>
228 + <key>ProcessType</key>
229 + <string>Background</string>
230 + <key>ProgramArguments</key>
231 + <array>
232 + <string>/bin/sh</string>
233 + <string>-c</string>
234 + <string>~/go/bin/ipfs daemon</string>
235 + </array>
236 + <key>RunAtLoad</key>
237 + <true/>
238 +</dict>
239 +</plist>
240 +```
241 +The reason for running `ipfs` under a shell is to avoid needing to hard-code the user's home directory in the job.
242 +
243 +- To start the job, run `launchctl load ~/Library/LaunchAgents/io.ipfs.go-ipfs.plist`
244 +
245 +Notes:
246 +
247 +- To check that the job is running, run `launchctl list | grep ipfs`.
248 +- IPFS should now start whenever you log in (and exit when you log out).
249 +- [LaunchControl](http://www.soma-zone.com/LaunchControl/) is a GUI tool which simplifies management of LaunchAgents.