Skip to content
This repository has been archived by the owner on Feb 12, 2024. It is now read-only.

Commit

Permalink
fix: print HTTP listeners only when run as daemon
Browse files Browse the repository at this point in the history
This changes behavior in web browser. Instead of printing to
console.log, it uses proper debug-based logger.

Old behavior in terminal (when run via `jsipfs daemon`) does not change.

License: MIT
Signed-off-by: Marcin Rataj <lidel@lidel.org>
  • Loading branch information
lidel committed Apr 11, 2019
1 parent cd2ccb0 commit 29a91ce
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/cli/standalone-daemon.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ class StandaloneDaemon {
this._ipfs = ipfs

// start HTTP servers (if API or Gateway is enabled in options)
const httpApi = new HttpApi(ipfs, ipfsOpts)
const httpApi = new HttpApi(ipfs, Object.assign({ announceListeners: true }, ipfsOpts))
this._httpApi = await httpApi.start()

this._log('started')
Expand Down
7 changes: 4 additions & 3 deletions src/http/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,14 +66,15 @@ class HttpApi {
const gatewayAddrs = config.Addresses.Gateway
this._gatewayServers = await serverCreator(gatewayAddrs, this._createGatewayServer, ipfs)

const announce = this._options.announceListeners ? ipfs._print : this._log
this._apiServers.forEach(apiServer => {
ipfs._print('API listening on %s', apiServer.info.ma)
announce('API listening on %s', apiServer.info.ma.toString())
})
this._gatewayServers.forEach(gatewayServer => {
ipfs._print('Gateway (read only) listening on %s', gatewayServer.info.ma)
announce('Gateway (read only) listening on %s', gatewayServer.info.ma.toString())
})
this._apiServers.forEach(apiServer => {
ipfs._print('Web UI available at %s', toUri(apiServer.info.ma) + '/webui')
announce('Web UI available at %s', toUri(apiServer.info.ma) + '/webui')
})
this._log('started')
return this
Expand Down

0 comments on commit 29a91ce

Please sign in to comment.