This repository has been archived by the owner on Feb 12, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' into refactor/use-exporter-w-cid-instances
- Loading branch information
Showing
66 changed files
with
562 additions
and
255 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
# Running multiple JS IPFS nodes | ||
|
||
This example takes you through the process needed to run 2 or more JS IPFS nodes on the same computer. | ||
|
||
## Via the CLI | ||
|
||
Firstly, you'll want to use the `IPFS_PATH` env variable to get a different repo for each instance. Initialise a new IPFS repo like this: | ||
|
||
```sh | ||
# IPFS_PATH by default is `~/.jsipfs`. | ||
# The following instructs JS IPFS to use the path `~/.jsipfs2` instead: | ||
IPFS_PATH=~/.jsipfs2 jsipfs init | ||
|
||
# Repeat this for as many nodes as you want to run... | ||
``` | ||
|
||
Secondly, you'll need them to bind to different ports because otherwise bad things happen. | ||
|
||
With the CLI, after you've run `ipfs init` you can either edit the config file at `~/.jsipfs/config` (replacing `~/.jsipfs` with the repo path you specified above) or use the config command to update the config e.g. `ipfs config Addresses.API /ip4/0.0.0.0/tcp/4012`. Then start the node with `ipfs daemon`: | ||
|
||
```sh | ||
# edit the address ports | ||
vi ~/.jsipfs2/config | ||
|
||
# OR | ||
|
||
IPFS_PATH=~/.jsipfs2 jsipfs config Addresses.API /ip4/127.0.0.1/tcp/5012 | ||
|
||
# Repeat this for as many nodes as you want to run... | ||
``` | ||
|
||
```sh | ||
# ...and then start the daemon | ||
IPFS_PATH=~/.jsipfs2 jsipfs daemon | ||
|
||
# Repeat this for as many nodes as you want to run... | ||
``` | ||
|
||
## Programmatically | ||
|
||
Firstly, you'll want to pass the [`repo`](https://github.com/ipfs/js-ipfs#optionsrepo) option to the constructor to get a different repo for each instance: | ||
|
||
```js | ||
// The repo path by default is `os.homedir() + '/.jsipfs'`. | ||
new IPFS({ repo: os.homedir() + '/.jsipfs2' }) | ||
``` | ||
|
||
Secondly, you'll need them to bind to different ports because otherwise bad things happen. | ||
|
||
To do this, simply pass the different ports to the [`config`](https://github.com/ipfs/js-ipfs#optionsconfig) constructor option. All together: | ||
|
||
```js | ||
new IPFS({ | ||
repo: os.homedir() + '/.jsipfs2', | ||
config: { | ||
Addresses: { | ||
Swarm: [ | ||
'/ip4/0.0.0.0/tcp/4012', | ||
'/ip4/127.0.0.1/tcp/4013/ws' | ||
], | ||
API: '/ip4/127.0.0.1/tcp/5012', | ||
Gateway: '/ip4/127.0.0.1/tcp/9191' | ||
} | ||
} | ||
}) | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.