How to use the ipfsd-ctl.local function in ipfsd-ctl

To help you get started, we’ve selected a few ipfsd-ctl examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github beakerbrowser / beaker / app / background-process / networks / ipfs.js View on Github external
export function setup () {
  // get a controller for the local ipfs node
  ipfsd.local((err, _ipfsNode) => {
    if (err) {
      // note the error
      // for now, let's keep the process running without ipfs, if it fails
      console.error('Failed to start IPFS')
      console.error(err)
      return
    }
    ipfsNode = _ipfsNode // save global

    // init and start the daemon
    if (ipfsNode.initialized)
      startDaemon()
    else {
      log('[IPFS] Initializing ~/.ipfs, keysize', KEYSIZE)
      ipfsNode.init({ keySize: KEYSIZE }, (err, res) => {
        if (err) {
github ipfs-shipyard / ipfs-desktop / src / init.js View on Github external
export function boot (lokker) {
  logger = lokker

  // main entry point
  ipfsd.local((err, node) => {
    if (err) {
      // We can't start if we fail to aquire
      // a ipfs node
      logger.error(err)
      process.exit(1)
    }

    mb = menubar(config.menuBar)

    // Ensure single instance
    mb.app.makeSingleInstance(reboot)

    mb.on('ready', () => {
      logger.info('Application is ready')

      // -- load the controls
github haadcode / ipfs-daemon / src / ipfs-native-daemon.js View on Github external
return new Promise((resolve, reject) => {
      ipfsd.local(this._options.IpfsDataDir, this._options, (err, node) => {
        if(err) 
          reject(err)

        this._daemon = node

        logger.debug("Initializing IPFS daemon")
        logger.debug(`Using IPFS repo at '${node.path}'`)

        // try {
        //   if (fs.lstatSync(this._options.IpfsDataDir)) {
        //     logger.debug(`IPFS repo already exists at '${node.path}'`)
        //     return resolve()
        //   }
        // } catch(e) {
        //   logger.debug(`IPFS repo doesn't exists at '${node.path}', creating a new one`)
        // }
github ipfs / js-ipfs / test / utils / interop-daemon-spawner / go.js View on Github external
(cb) => {
        if (this.disposable) {
          const config = Object.assign({ init: this.init }, this.config)
          ctl.disposable(config, cb)
        } else if (this.init) {
          ctl.local(this.path, (err, node) => {
            if (err) {
              return cb(err)
            }
            node.init((err) => cb(err, node))
          })
        } else {
          ctl.local(this.path, cb)
        }
      },
      (node, cb) => {
github ipfs / js-ipfs / test / utils / interop-daemon-spawner / go.js View on Github external
(cb) => {
        if (this.disposable) {
          const config = Object.assign({ init: this.init }, this.config)
          ctl.disposable(config, cb)
        } else if (this.init) {
          ctl.local(this.path, (err, node) => {
            if (err) {
              return cb(err)
            }
            node.init((err) => cb(err, node))
          })
        } else {
          ctl.local(this.path, cb)
        }
      },
      (node, cb) => {
github ipfs-shipyard / ipfs-npm-OLD / lib / ipfs.js View on Github external
var getApi = W(function * (w) {
    if (ipfsApi) return ipfsApi
    try {
      ipfsApi = IpfsApi('localhost', 5001)
      yield ipfsApi.id(w)
    } catch (e) {
      yield mkdirp(inpmPath, w)
      var node = yield ipfsd.local(ipfsPath, w)
      if (!(yield utils.exists(ipfsPath, w))) {
        yield node.init(w)
      }
      ipfsApi = yield node.startDaemon(w)
    }
    return ipfsApi
  })
github BusterLabs / Partyshare / src / electron / classes / IPFSSync.js View on Github external
return new Promise((resolve, reject) => {
            ipfsCtl.local(IPFS_REPO, {}, (err, node) => {
                if (err) {
                    logger.error('[IPFSSync] _getNode', err);
                    reject(err);
                    return;
                }

                resolve(node);
            });
        });
    }