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

Commit 29a91ce

Browse files
committed
fix: print HTTP listeners only when run as daemon
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>
1 parent cd2ccb0 commit 29a91ce

File tree

2 files changed

+5
-4
lines changed

2 files changed

+5
-4
lines changed

src/cli/standalone-daemon.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ class StandaloneDaemon {
6969
this._ipfs = ipfs
7070

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

7575
this._log('started')

src/http/index.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -66,14 +66,15 @@ class HttpApi {
6666
const gatewayAddrs = config.Addresses.Gateway
6767
this._gatewayServers = await serverCreator(gatewayAddrs, this._createGatewayServer, ipfs)
6868

69+
const announce = this._options.announceListeners ? ipfs._print : this._log
6970
this._apiServers.forEach(apiServer => {
70-
ipfs._print('API listening on %s', apiServer.info.ma)
71+
announce('API listening on %s', apiServer.info.ma.toString())
7172
})
7273
this._gatewayServers.forEach(gatewayServer => {
73-
ipfs._print('Gateway (read only) listening on %s', gatewayServer.info.ma)
74+
announce('Gateway (read only) listening on %s', gatewayServer.info.ma.toString())
7475
})
7576
this._apiServers.forEach(apiServer => {
76-
ipfs._print('Web UI available at %s', toUri(apiServer.info.ma) + '/webui')
77+
announce('Web UI available at %s', toUri(apiServer.info.ma) + '/webui')
7778
})
7879
this._log('started')
7980
return this

0 commit comments

Comments
 (0)