You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
> `DaemonFactory.create([options])` returns an object that will expose the `df.spawn` method
120
+
`DaemonFactory.create([options])` returns an object that will expose the `df.spawn` method
118
121
119
122
-`options` - an optional object with the following properties
120
123
-`remote` bool - indicates if the factory should spawn local or remote nodes. By default, local nodes are spawned in Node.js and remote nodes are spawned in Browser environments.
121
124
-`port` number - the port number to use for the remote factory. It should match the port on which `DaemonFactory.server` was started. Defaults to 9999.
122
-
- type - the daemon type to create with this factory. See the section bellow for the supported types
125
+
-`type` - the daemon type to create with this factory. See the section bellow for the supported types
126
+
-`exec` - path to the desired IPFS executable to spawn, otherwise `ipfsd-ctl` will try to locate the correct one based on the `type`. In the case of `proc` type, exec is required and expects an IPFS coderef.
123
127
124
-
##### IPFS executable types
125
-
126
-
`ipfsd-ctl` allows spawning different types of executables, such as:
127
-
128
-
> `go`
129
-
130
-
Invoking `df.create({type: 'go'})` will spawn a `go-ipfs` node.
131
-
132
-
> `js`
133
-
134
-
Invoking `df.create({type: 'js'})` will spawn a `js-ipfs` node.
135
-
136
-
> `proc`
137
-
138
-
Invoking `df.create({type: 'proc'})` will spawn an `in-process-ipfs` node using the provided code reference that implements the core IPFS API. Note that, `exec` option to `df.spawn()` is required if `type: 'proc'` is used.
128
+
`ipfsd-ctl` allows spawning different IPFS implementations, such as:
139
129
130
+
-**`go`** - calling `DaemonFactory.create({type: 'go'})` will spawn a `go-ipfs` daemon.
131
+
-**`js`** - calling `DaemonFactory.create({type: 'js'})` will spawn a `js-ipfs` daemon.
132
+
-**`proc`** - calling `DaemonFactory.create({type: 'proc', exec: require('ipfs') })` will spawn an `in process js-ipfs node` using the provided code reference that implements the core IPFS API. Note that, `exec` option to `df.spawn()` is required if `type: 'proc'` is used.
140
133
134
+
#### DaemonFactory endpoint for remote spawning - `const server = DaemonFactory.createServer([options]) `
141
135
142
-
#### Create a DaemonFactory Endpoint - `const server = DaemonFactory.createServer([options]) `
143
-
144
-
> `DaemonFactory.createServer` create an instance of the bundled REST API used by the remote controller.
136
+
`DaemonFactory.createServer` create an instance of the bundled REST API used by the remote controller.
145
137
146
-
- exposes `start` and `stop` methods to start and stop the http server.
138
+
- exposes `start` and `stop` methods to start and stop the http server endpoint.
147
139
148
140
#### Spawn a new daemon with `df.spawn`
149
141
150
-
> Spawn either a js-ipfs or go-ipfs node
142
+
Spawn either a js-ipfs or go-ipfs daemon
151
143
152
-
`spawn([options], callback)`
144
+
`df.spawn([options], callback)`
153
145
154
-
-`options`- is an optional object the following properties
146
+
`options` is an optional object the following properties:
155
147
-`init` bool (default true) - should the node be initialized
156
148
-`start` bool (default true) - should the node be started
157
149
-`repoPath` string - the repository path to use for this node, ignored if node is disposable
158
150
-`disposable` bool (default false) - a new repo is created and initialized for each invocation, as well as cleaned up automatically once the process exits
159
151
-`args` - array of cmd line arguments to be passed to ipfs daemon
160
152
-`config` - ipfs configuration options
161
-
-`exec` - path to the desired IPFS executable to spawn, otherwise `ipfsd-ctl` will try to locate the correct one based on the `type`. In the case of `proc` type, exec is required and expects an IPFS coderef
162
-
163
-
-`callback` - is a function with the signature `cb(err, ipfsd)` where:
164
-
-`err` - is the error set if spawning the node is unsuccessful
165
-
-`ipfsd` - is the daemon controller instance:
166
-
-`api` - a property of `ipfsd`, an instance of [ipfs-api](https://github.com/ipfs/js-ipfs-api) attached to the newly created ipfs node
167
-
168
-
### IPFS Daemon Controller (ipfsd)
169
-
170
-
> The IPFS daemon controller that allows interacting with the spawned IPFS process
171
153
172
-
#### `apiAddr` (getter)
154
+
`callback` - is a function with the signature `function (err, ipfsd)` where:
155
+
-`err` - is the error set if spawning the node is unsuccessful
156
+
-`ipfsd` - is the daemon controller instance:
157
+
-`api` - a property of `ipfsd`, an instance of [ipfs-api](https://github.com/ipfs/js-ipfs-api) attached to the newly created ipfs node
173
158
174
-
> Get the address (multiaddr) of connected IPFS API.
159
+
### IPFS Daemon Controller (`ipfsd`)
175
160
176
-
- returns multiaddr
161
+
The IPFS daemon controller (`ipfsd`) allows you to interact with the spawned IPFS daemon.
177
162
178
-
#### `gatewayAddr` (getter)
163
+
#### `ipfsd.apiAddr` (getter)
179
164
180
-
> Get the address (multiaddr) of connected IPFS HTTP Gateway.
165
+
Get the address (multiaddr) of connected IPFS API. Returns a multiaddr,
181
166
182
-
- returns multiaddr
167
+
#### `ipfsd.gatewayAddr` (getter)
183
168
184
-
#### `repoPath` (getter)
169
+
Get the address (multiaddr) of connected IPFS HTTP Gateway. Returns a multiaddr.
185
170
186
-
> Get the current repo path.
171
+
#### `ipfsd.repoPath` (getter)
187
172
188
-
- returns string
173
+
Get the current repo path. Returns string
189
174
190
-
#### `started` (getter)
175
+
#### `ipfsd.started` (getter)
191
176
192
-
> Is the node started.
193
-
194
-
- returns boolean
177
+
Is the node started. Returns a boolean.
195
178
196
-
#### `init([initOpts], callback)`
179
+
#### `init([initOpts], callback)`
197
180
198
-
> Initialize a repo.
181
+
Initialize a repo.
199
182
200
-
-`initOpts` (optional) - options object with the following entries
183
+
`initOpts` (optional) is an object with the following properties:
201
184
-`keysize` (default 2048) - The bit size of the identiy key.
202
185
-`directory` (default IPFS_PATH if defined, or ~/.ipfs for go-ipfs and ~/.jsipfs for js-ipfs) - The location of the repo.
203
-
-`function (Error, Node)` callback - receives an instance of this Node on success or an instance of `Error` on failure
204
-
205
-
206
-
#### `cleanup (callback)`
207
-
208
-
> Delete the repo that was being used. If the node was marked as `disposable` this will be called automatically when the process is exited.
186
+
187
+
`callback` is a function with the signature `function (Error, ipfsd)` where `err` is an Error in case something goes wrong and `ipfsd` is the daemon controller instance.
209
188
210
-
-`function(Error)` callback
189
+
#### `ipfsd.cleanup(callback)`
211
190
212
-
#### `start (flags, callback)`
191
+
Delete the repo that was being used. If the node was marked as `disposable` this will be called automatically when the process is exited.
213
192
214
-
> Start the daemon.
193
+
`callback` is a function with the signature `function(err)`.
215
194
216
-
-`flags` - Flags array to be passed to the `ipfs daemon` command.
217
-
-`function(Error, IpfsApi)}` callback - function that receives an instance of `ipfs-api` on success or an instance of `Error` on failure
195
+
#### `ipfsd.start(flags, callback)`
218
196
197
+
Start the daemon.
219
198
220
-
#### `stop (callback)`
199
+
`flags` - Flags array to be passed to the `ipfs daemon` command.
221
200
222
-
> Stop the daemon.
201
+
`callback` is a function with the signature `function(err, ipfsApi)}` that receives an instance of `ipfs-api` on success or an instance of `Error` on failure
223
202
224
-
-`function(Error)` callback - function that receives an instance of `Error` on failure
225
203
226
-
#### `killProcess (callback)`
204
+
#### `ipfsd.stop(callback)`
227
205
228
-
> Kill the `ipfs daemon` process.
206
+
Stop the daemon.
229
207
230
-
First `SIGTERM` is sent, after 10.5 seconds `SIGKILL` is sent if the process hasn't exited yet.
208
+
`callback` is a function with the signature `function(err)` callback - function that receives an instance of `Error` on failure
231
209
232
-
-`function()` callback - Called once the process is killed
210
+
#### `ipfsd.killProcess (callback)`
233
211
212
+
Kill the `ipfs daemon` process.
234
213
235
-
#### `pid ()`
214
+
First a `SIGTERM` is sent, after 10.5 seconds `SIGKILL` is sent if the process hasn't exited yet.
236
215
237
-
> Get the pid of the `ipfs daemon`process.
216
+
`callback` is a function with the signature `function()` called once the process is killed
238
217
239
-
- returns the pid number
218
+
#### `ipfsd.pid ()`
240
219
220
+
Get the pid of the `ipfs daemon` process. Returns the pid number
241
221
242
-
#### `getConfig(key, callback)`
222
+
#### `ipfsd.getConfig(key, callback)`
243
223
244
-
> Call `ipfs config`
224
+
Returns the output of an `ipfs config` command. If no `key` is passed, the whole config is returned as an object.
245
225
246
-
If no `key`is passed, the whole config is returned as an object.
226
+
`key`(optional) - A specific config to retrieve.
247
227
248
-
-`key` (optional) - A specific config to retrieve.
249
-
-`function(Error, (Object|string)` callback - function that receives an object or string on success or an `Error` instance on failure
228
+
`callback` is a function with the signature `function(err, (Object|string)` that receives an object or string on success or an `Error` instance on failure
250
229
230
+
#### `ipfsd.setConfig (key, value, callback)`
251
231
252
-
#### `setConfig (key, value, callback)`
232
+
Set a config value.
253
233
254
-
> Set a config value.
234
+
`key` - the key of the config entry to change/set
255
235
256
-
-`key` - the key of the config entry to change/set
257
-
-`value` - the config value to change/set
258
-
-`function(Error)` callback - function that receives an `Error` instance on failure
236
+
`value` - the config value to change/set
259
237
238
+
`callback` is a function with the signature `function(err)` callback - function that receives an `Error` instance on failure
260
239
261
-
#### `version(callback)`
240
+
#### `ipfsd.version(callback)`
262
241
263
-
> Get the version of ipfs
242
+
Get the version of ipfs
264
243
265
-
-`function(Error, string)` callback
244
+
`callback` is a function with the signature `function(err, version)`
266
245
267
246
### IPFS Client (`ipfsd.api`)
268
247
269
-
> An instance of [ipfs-api](https://github.com/ipfs/js-ipfs-api#api)
248
+
An instance of [ipfs-api](https://github.com/ipfs/js-ipfs-api#api) that is used to interact with the daemon.
270
249
271
250
This instance is returned for each successfully started IPFS daemon, when either `df.spawn({start: true})` (the default) is called, or `ipfsd.start()` is invoked in the case of nodes that were spawned with `df.spawn({start: false})`.
272
251
273
252
### Packaging
274
253
275
-
`ipfsd-ctl` can be packaged in Electron applications, but the ipfs binary
276
-
has to be excluded from asar (Electron Archives),
254
+
`ipfsd-ctl` can be packaged in Electron applications, but the ipfs binary has to be excluded from asar (Electron Archives),
277
255
[read more about unpack files from asar](https://electron.atom.io/docs/tutorial/application-packaging/#adding-unpacked-files-in-asar-archive).
278
-
`ipfsd-ctl` will try to detect if used from within an `app.asar` archive
279
-
and tries to resolve ipfs from `app.asar.unpacked`. The ipfs binary is part of
280
-
the `go-ipfs-dep` module.
256
+
257
+
`ipfsd-ctl` will try to detect if used from within an `app.asar` archive and tries to resolve ipfs from `app.asar.unpacked`. The ipfs binary is part of the `go-ipfs-dep` module.
0 commit comments