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

Commit a2a307d

Browse files
committed
refactor: rename StandaloneDaemon to Daemon
License: MIT Signed-off-by: Marcin Rataj <[email protected]>
1 parent 7c32da8 commit a2a307d

File tree

5 files changed

+26
-26
lines changed

5 files changed

+26
-26
lines changed

src/cli/commands/daemon.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,8 @@ module.exports = {
4444
const repoPath = getRepoPath()
4545

4646
// Required inline to reduce startup time
47-
const StandaloneDaemon = require('../../cli/standalone-daemon')
48-
const daemon = new StandaloneDaemon({
47+
const Daemon = require('../../cli/daemon')
48+
const daemon = new Daemon({
4949
silent: argv.silent,
5050
repo: process.env.IPFS_PATH,
5151
offline: argv.offline,

src/cli/standalone-daemon.js renamed to src/cli/daemon.js

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,10 @@ const TCP = require('libp2p-tcp')
99
const MulticastDNS = require('libp2p-mdns')
1010
const WS = require('libp2p-websockets')
1111
const Bootstrap = require('libp2p-bootstrap')
12+
const promisify = require('promisify-es6')
13+
const toUri = require('multiaddr-to-uri')
1214

13-
class StandaloneDaemon {
15+
class Daemon {
1416
constructor (options) {
1517
this._options = options || {}
1618
this._log = debug('ipfs:daemon')
@@ -69,9 +71,24 @@ class StandaloneDaemon {
6971
this._ipfs = ipfs
7072

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

77+
// for the CLI to know the where abouts of the API
78+
if (this._httpApi._apiServers.length) {
79+
await promisify(ipfs._repo.apiAddr.set)(this._httpApi._apiServers[0].info.ma)
80+
}
81+
82+
this._httpApi._apiServers.forEach(apiServer => {
83+
ipfs._print('API listening on %s', apiServer.info.ma.toString())
84+
})
85+
this._httpApi._gatewayServers.forEach(gatewayServer => {
86+
ipfs._print('Gateway (read only) listening on %s', gatewayServer.info.ma.toString())
87+
})
88+
this._httpApi._apiServers.forEach(apiServer => {
89+
ipfs._print('Web UI available at %s', toUri(apiServer.info.ma) + '/webui')
90+
})
91+
7592
this._log('started')
7693
return this
7794
}
@@ -87,4 +104,4 @@ class StandaloneDaemon {
87104
}
88105
}
89106

90-
module.exports = StandaloneDaemon
107+
module.exports = Daemon

src/http/index.js

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,6 @@ const Hapi = require('hapi')
44
const Pino = require('hapi-pino')
55
const debug = require('debug')
66
const multiaddr = require('multiaddr')
7-
const promisify = require('promisify-es6')
8-
const toUri = require('multiaddr-to-uri')
97
const toMultiaddr = require('uri-to-multiaddr')
108

119
const errorHandler = require('./error-handler')
@@ -69,24 +67,9 @@ class HttpApi {
6967
const apiAddrs = config.Addresses.API
7068
this._apiServers = await serverCreator(apiAddrs, this._createApiServer, ipfs)
7169

72-
// for the CLI to know the where abouts of the API
73-
if (this._apiServers.length) {
74-
await promisify(ipfs._repo.apiAddr.set)(this._apiServers[0].info.ma)
75-
}
76-
7770
const gatewayAddrs = config.Addresses.Gateway
7871
this._gatewayServers = await serverCreator(gatewayAddrs, this._createGatewayServer, ipfs)
7972

80-
const announce = this._options.announceListeners ? ipfs._print : this._log
81-
this._apiServers.forEach(apiServer => {
82-
announce('API listening on %s', apiServer.info.ma.toString())
83-
})
84-
this._gatewayServers.forEach(gatewayServer => {
85-
announce('Gateway (read only) listening on %s', gatewayServer.info.ma.toString())
86-
})
87-
this._apiServers.forEach(apiServer => {
88-
announce('Web UI available at %s', toUri(apiServer.info.ma) + '/webui')
89-
})
9073
this._log('started')
9174
return this
9275
}

test/gateway/index.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ const chai = require('chai')
55
const dirtyChai = require('dirty-chai')
66
const expect = chai.expect
77
chai.use(dirtyChai)
8-
const StandaloneDaemon = require('../../src/cli/standalone-daemon')
8+
const Daemon = require('../../src/cli/daemon')
99
const loadFixture = require('aegir/fixtures')
1010
const os = require('os')
1111
const path = require('path')
@@ -33,7 +33,7 @@ describe('HTTP Gateway', function () {
3333
this.timeout(60 * 1000)
3434
const repoPath = path.join(os.tmpdir(), '/ipfs-' + hat())
3535

36-
http.api = new StandaloneDaemon({
36+
http.api = new Daemon({
3737
repo: repoPath,
3838
init: true,
3939
config: {

test/http-api/routes.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ const chai = require('chai')
66
const dirtyChai = require('dirty-chai')
77
chai.use(dirtyChai)
88
const hat = require('hat')
9-
const StandaloneDaemon = require('../../src/cli/standalone-daemon')
9+
const Daemon = require('../../src/cli/daemon')
1010
const promisify = require('promisify-es6')
1111
const ncp = promisify(require('ncp').ncp)
1212
const path = require('path')
@@ -22,7 +22,7 @@ describe('HTTP API', () => {
2222
let http = {}
2323

2424
const startHttpAPI = async (config) => {
25-
http.api = new StandaloneDaemon({
25+
http.api = new Daemon({
2626
repo: repoTests,
2727
pass: hat(),
2828
config,

0 commit comments

Comments
 (0)