|
1 | 1 | # Dats on a Server |
2 | 2 |
|
3 | | -After you create your dat and close your laptop, other people won't be able to access your data. You might want a server that is always running, that archives and mirrors your dats, so that your dats are accessible at all times of the day. |
| 3 | +Since Dat is a distributed (peer-to-peer) data sharing tool, a computer must be actively sharing a dat for it to be available. If you're sharing files over Dat, you might want to set up a dedicated server that re-hosts your dat. This means that it'll still be available even after you turn off your personal computer. |
4 | 4 |
|
5 | | -## TLDR |
6 | | -To host a dat on your server: |
| 5 | +Running Dat on a server can also be used for live backups. As long as you are connected to your server and syncing changes, your server can backup all of your content history - allowing you to view old content later. |
7 | 6 |
|
| 7 | +## Short Instructions |
| 8 | + |
| 9 | +We have built a simple tool to host multiple dats using the commandline. The tool is called `hypercored`. Hypercored reads a file that contains all of the dats that you want to share. |
| 10 | + |
| 11 | +Install it on your server, create a `feeds` file with dats separated by newlines, and run `hypercored`. |
| 12 | + |
| 13 | +``` |
| 14 | +npm install -g hypercored |
| 15 | +echo 'dat://64375abb733a62fa301b1f124427e825d292a6d3ba25a26c9d4303a7987bec65' >> feeds |
| 16 | +echo 'dat://another-dat-link-here' >> feeds |
| 17 | +hypercored |
| 18 | +``` |
| 19 | + |
| 20 | +That's it. Now it will download and host the data for the each dat in the `feeds` file. Hypercored uses [hypercore-archiver](https://github.com/mafintosh/hypercore-archiver) for efficient sharing of many dats and full content history backup. |
| 21 | + |
| 22 | +See below for more detailed instructions. |
| 23 | + |
| 24 | +## Detailed Instructions |
| 25 | + |
| 26 | +### Node Version |
| 27 | + |
| 28 | +Check your node version, you should have version 4.0 or higher, but 6.10.3 or higher is preferred. |
| 29 | + |
| 30 | +``` |
| 31 | +$ node -v |
8 | 32 | ``` |
9 | | - npm install -g dat lil-pids add-to-systemd |
10 | | - mkdir ~/dats |
11 | | - echo "dat dat://ff34725120b2f3c5bd5028e4f61d14a45a22af48a7b12126d5d588becde88a93/ \ |
12 | | - ~/dats/datprotocol \ |
13 | | - --quiet" > ~/dats/services |
14 | | - sudo add-to-systemd dat-lil-pids $(which lil-pids) ~/dats/services ~/dats/pids |
15 | | - sudo systemctl start dat-lil-pids |
| 33 | + |
| 34 | +Then, go to your server (using `ssh username@hostname.com`) and install `hypercored`: |
| 35 | + |
16 | 36 | ``` |
| 37 | +npm install -g hypercored |
| 38 | +``` |
| 39 | + |
| 40 | +If you have installation trouble due to a permissions error, please see [this tutorial for fixing permissions in node.js](https://docs.npmjs.com/getting-started/fixing-npm-permissions). |
| 41 | + |
| 42 | +Now, create a file called 'feeds' with the list of dats you want to share. |
| 43 | + |
| 44 | +feeds |
| 45 | +``` |
| 46 | +dat://one-hash |
| 47 | +two-hash |
| 48 | +website.com/three-hash |
| 49 | +``` |
| 50 | + |
| 51 | +So then if you `ls` you should see `feeds` in the list of files. |
| 52 | + |
| 53 | +``` |
| 54 | +$ ls |
| 55 | +feeds |
| 56 | +``` |
| 57 | + |
| 58 | +Now, to share these dats simply type `hypercored` in the same directory. |
| 59 | + |
| 60 | +``` |
| 61 | +~/dat $ hypercored |
| 62 | +Watching ~/dat/feeds for a list of active feeds |
| 63 | +Archiver key is 42471e32d36be3cb617ec1df382372532aac1d1ce683982962fb3594c5f9532a |
| 64 | +Swarm listening on port 58184 |
| 65 | +``` |
| 66 | + |
| 67 | +That's great! Now all of the dats in `feeds` will be downloaded and re-hosted. However, it's running in the foreground -- you probably want to use a process manager to run and watch the process so that it never goes down. |
| 68 | + |
| 69 | +## Run it Forever |
| 70 | + |
| 71 | +We recommend using `lil-pids` and `add-to-systemd` for long-term dat hosting from a linux server. |
| 72 | + |
| 73 | +``` |
| 74 | +npm install -g add-to-systemd lil-pids |
| 75 | +mkdir ~/dat |
| 76 | +echo "hypercored --cwd ~/dat" > ~/dat/services |
| 77 | +sudo add-to-systemd dat-lil-pids $(which lil-pids) ~/dat/services ~/dat/pids |
| 78 | +``` |
| 79 | + |
| 80 | +Replace `~` with the path where you want to store your dats. |
0 commit comments