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

Commit 0b9076d

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 <[email protected]>
1 parent a3e0bd4 commit 0b9076d

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
@@ -77,14 +77,15 @@ class HttpApi {
7777
const gatewayAddrs = config.Addresses.Gateway
7878
this._gatewayServers = await serverCreator(gatewayAddrs, this._createGatewayServer, ipfs)
7979

80+
const announce = this._options.announceListeners ? ipfs._print : this._log
8081
this._apiServers.forEach(apiServer => {
81-
ipfs._print('API listening on %s', apiServer.info.ma)
82+
announce('API listening on %s', apiServer.info.ma.toString())
8283
})
8384
this._gatewayServers.forEach(gatewayServer => {
84-
ipfs._print('Gateway (read only) listening on %s', gatewayServer.info.ma)
85+
announce('Gateway (read only) listening on %s', gatewayServer.info.ma.toString())
8586
})
8687
this._apiServers.forEach(apiServer => {
87-
ipfs._print('Web UI available at %s', toUri(apiServer.info.ma) + '/webui')
88+
announce('Web UI available at %s', toUri(apiServer.info.ma) + '/webui')
8889
})
8990
this._log('started')
9091
return this

0 commit comments

Comments
 (0)