Skip to content

Commit 93ad289

Browse files
committed
fix: fixes #59 and #60 with better error detection and messages
1 parent bd2b8ff commit 93ad289

File tree

3 files changed

+60
-31
lines changed

3 files changed

+60
-31
lines changed

README.md

Lines changed: 43 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -71,41 +71,48 @@ ipfs-npm
7171
Starts a registry server that uses IPFS to fetch js dependencies
7272

7373
Options:
74-
--help Show help [boolean]
75-
--version Show version number [boolean]
76-
--clone Whether to clone the registry in the background
74+
--help Show help [boolean]
75+
--version Show version number [boolean]
76+
--clone Whether to clone the registry in the background
7777
[default: true]
78-
--eager-download Whether to eagerly download tarballs [default: true]
79-
--mirror-host Which host to listen to requests on
78+
--eager-download Whether to eagerly download tarballs
79+
[default: true]
80+
--mirror-host Which host to listen to requests on
8081
[default: "localhost"]
81-
--mirror-port Which port to listen to requests on [default: 50321]
82-
--mirror-protocol Which protocol to use with the server
82+
--mirror-port Which port to listen to requests on
83+
[default: 50321]
84+
--mirror-protocol Which protocol to use with the server
8385
[default: "http"]
84-
--mirror-registry Where to download missing files from
86+
--mirror-registry Where to download missing files from/proxy for
87+
non-get requests
8588
[default: "https://registry.npmjs.com"]
86-
--ipfs-port Which port the daemon is listening on[default: null]
87-
--external-host Which host to use when reaching this mirror
88-
--external-port Which port to use when reaching this mirror
89-
--external-protocol Which protocol to use when reaching this mirror
90-
--ipfs-host Which host the daemon is listening on[default: null]
91-
--ipfs-base-dir Which mfs prefix to use
89+
--mirror-upload-size-limit How large a file upload to allow when proxying for
90+
the registry [default: "1024mb"]
91+
--ipfs-port Which port the daemon is listening on
92+
[default: null]
93+
--external-host Which host to use when reaching this mirror
94+
--external-port Which port to use when reaching this mirror
95+
--external-protocol Which protocol to use when reaching this mirror
96+
--ipfs-host Which host the daemon is listening on
97+
[default: "localhost"]
98+
--ipfs-base-dir Which mfs prefix to use
9299
[default: "/commons-registry"]
93-
--ipfs-flush Whether to flush the MFS cache [default: true]
94-
--ipfs-max-requests How many concurrent requests to make to the IPFS
95-
daemon [default: 5]
96-
--ipfs-type "proc" to start an in process node, "go" or "js" to
97-
connect to a remote daemon (in conjunction with
98-
--ipfs-port and --ipfs-host). [default: "proc"]
99-
--clone-skim Which registry to clone
100+
--ipfs-flush Whether to flush the MFS cache [default: true]
101+
--ipfs-max-requests How many concurrent requests to make to the IPFS
102+
daemon [default: 5]
103+
--ipfs-type "proc" to start an in process node, "go" or "js"
104+
to connect to a remote daemon (in conjunction with
105+
--ipfs-port and --ipfs-host). [default: "proc"]
106+
--clone-skim Which registry to clone
100107
[default: "https://replicate.npmjs.com/registry"]
101-
--clone-user-agent What user agent to specify when contacting the
102-
registry [default: "IPFS registry-mirror worker"]
103-
--clone-delay How long in ms to wait between cloning each module
104-
[default: 0]
105-
--clone-upgrade-to-https If a tarball is specifed with an http URL, whether
106-
to upgrade it to https [default: true]
107-
--request-max-sockets How many concurrent http requests to make while
108-
cloning the repo [default: 10]
108+
--clone-user-agent What user agent to specify when contacting the
109+
registry [default: "IPFS registry-mirror worker"]
110+
--clone-delay How long in ms to wait between cloning each module
111+
[default: 1000]
112+
--clone-upgrade-to-https If a tarball is specifed with an http URL, whether
113+
to upgrade it to https [default: true]
114+
--request-max-sockets How many concurrent http requests to make while
115+
cloning the repo [default: 10]
109116
```
110117
111118
## Docker
@@ -115,6 +122,13 @@ $ docker-compose build
115122
$ docker-compose up -d --scale registry=4
116123
```
117124
125+
### Upgrading
126+
127+
```
128+
$ docker-compose stop registry
129+
$ docker-compose up -d --no-deps --build --scale registry=n registry
130+
```
131+
118132
## Important
119133
120134
If you are on Mac OS X, make sure to increase the limit of files open (with `ulimit -Sn 4096`), otherwise the ipfs daemon will be sad and throw 502 replies.

src/cli/bin.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ yargs.command('$0', 'Starts a registry server that uses IPFS to fetch js depende
5353
})
5454
.option('ipfs-host', {
5555
describe: 'Which host the daemon is listening on',
56-
default: null
56+
default: 'localhost'
5757
})
5858
.option('ipfs-base-dir', {
5959
describe: 'Which mfs prefix to use',

src/core/mirror/index.js

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,22 @@ module.exports = async (options) => {
7272
console.info('😈 Using in-process IPFS daemon')
7373
}
7474

75-
const blobStore = await ipfsBlobStore(options.store)
75+
let blobStore
76+
77+
try {
78+
blobStore = await ipfsBlobStore(options.store)
79+
} catch (error) {
80+
const message = error && error.message || ''
81+
82+
if (message.includes('repo.lock') && message.includes('EAGAIN')) {
83+
console.error('💥 Could not open IPFS repo, is an IPFS node already running?')
84+
console.error('💥 If so, please try again with --ipfs-port=5001 (go-ipfs) or --ipfs-port=5002 (js-ipfs)')
85+
86+
process.exit(1)
87+
}
88+
89+
throw error
90+
}
7691

7792
if (options.clone.enabled) {
7893
clone(options, blobStore)

0 commit comments

Comments
 (0)