Intro
Installable via npm install --save ipfsd-ctl
, it can also be used directly in the browser.
Download
The source is available for download from GitHub. Alternatively, you can install using npm:
$ npm install --save ipfsd-ctl
You can then require()
ipfsd-ctl as normal:
const ipfsdCtl = require('ipfsd-ctl')
In the Browser
Ipfsd-ctl should work in any ES2015 environment out of the box.
Usage:
<script type="text/javascript" src="index.js"></script>
The portable versions of ipfsd-ctl, including index.js
and index.min.js
, are included in the /dist
folder. Ipfsd-ctl can also be found on unkpkg.com under
Daemon
ipfsd for a go-ipfs or js-ipfs daemon
Parameters
opts: Object?
:
instance
Daemon.prototype.gatewayAddr
gatewayAddr
Get the address of connected IPFS HTTP Gateway.
Returns
Multiaddr
Daemon.prototype.init
init(initOptions: Object, callback: function (Error, Node)): undefined
Initialize a repo.
Parameters
Returns
Daemon.prototype.cleanup
cleanup(callback: function (Error)): undefined
Delete the repo that was being used.
If the node was marked as disposable
this will be called
automatically when the process is exited.
Parameters
callback: function (Error)
:
Returns
Daemon.prototype.start
start(flags: Array<string>, callback: function (Error, IpfsApi)): undefined
Start the daemon.
Parameters
callback: function (Error, IpfsApi)
:
Returns
Daemon.prototype.stop
stop(callback: function (Error)): undefined
Stop the daemon.
Parameters
callback: function (Error)
:
Returns
Daemon.prototype.killProcess
killProcess(callback: function ()): undefined
Kill the ipfs daemon
process.
First SIGTERM
is sent, after 10.5 seconds SIGKILL
is sent
if the process hasn't exited yet.
Parameters
callback: function ()
:Called when the process was killed.
Returns
Daemon.prototype.pid
pid(callback: function ()): undefined
Get the pid of the ipfs daemon
process.
Parameters
callback: function ()
:receives the pid
Returns
Daemon.prototype.getConfig
getConfig(key: string?, callback: function (Error, (Object | string))): undefined
Call ipfs config
If no key
is passed, the whole config is returned as an object.
Parameters
key: string?
:A specific config to retrieve.
Returns
Daemon.prototype.setConfig
setConfig(key: string, value: string, callback: function (Error)): undefined
Set a config value.
Returns
tmpDir
Utility method to get a temporary directory useful in browsers to be able to generate temp repos manually
Returns
FactoryInProc
Spawn JSIPFS instances (aka in process nodes)
static
instance
FactoryInProc.prototype.tmpDir
tmpDir(type: string, callback: function (Error, string)): undefined
Utility method to get a temporary directory useful in browsers to be able to generate temp repos manually
Here for completeness
Returns
FactoryInProc.prototype.spawn
spawn(opts: Object, callback: Function): undefined
Spawn JSIPFS instances
Options are:
init
{bool|Object} - should the node be initializedinitOptions
Object, it is expected to be of the form{bits: <size>}
, which sets the desired key sizestart
bool - should the node be startedrepoPath
string - the repository path to use for this node, ignored if node is disposabledisposable
bool - a new repo is created and initialized for each invocationconfig
- ipfs configuration optionsargs
- array of cmd line arguments to be passed to ipfs daemonexec
string (optional) - path to the desired IPFS executable to spawn, this will override theexec
set when creating the daemon controller factory instance
Parameters
Returns
cleanup
Delete the repo that was being used.
If the node was marked as disposable
this will be called
automatically when the process is exited.
Parameters
cb: function (Error)
:
Returns
killProcess
Kill the ipfs daemon
process.
First SIGTERM
is sent, after 7.5 seconds SIGKILL
is sent
if the process hasn't exited yet.
Parameters
cb: function ()?
:Called when the process was killed.
Returns
Node
ipfsd for a js-ipfs instance (aka in-process IPFS node)
Parameters
opts: Object?
:
instance
Node.prototype.gatewayAddr
gatewayAddr
Get the address of connected IPFS HTTP Gateway.
Returns
Multiaddr
Node.prototype.init
init(initOptions: Object, callback: function (Error, Node)): undefined
Initialize a repo.
Parameters
Returns
Node.prototype.cleanup
cleanup(callback: function (Error)): undefined
Delete the repo that was being used.
If the node was marked as disposable
this will be called
automatically when the process is exited.
Parameters
callback: function (Error)
:
Returns
Node.prototype.start
start(flags: Array<string>, callback: function (Error, IpfsApi)): undefined
Start the daemon.
Parameters
callback: function (Error, IpfsApi)
:
Returns
Node.prototype.stop
stop(callback: function (Error)?): undefined
Stop the daemon.
Parameters
callback: function (Error)?
:
Returns
Node.prototype.killProcess
killProcess(callback: function ()): undefined
Kill the ipfs daemon
process.
First SIGTERM
is sent, after 10.5 seconds SIGKILL
is sent
if the process hasn't exited yet.
Parameters
callback: function ()
:Called when the process was killed.
Returns
Node.prototype.getConfig
getConfig(key: string?, callback: function (Error, (Object | string))): undefined
Call ipfs config
If no key
is passed, the whole config is returned as an object.
Parameters
key: string?
:A specific config to retrieve.
Returns
Node.prototype.setConfig
setConfig(key: string, value: string, callback: function (Error)): undefined
Set a config value.