Skip to content

Commit 4b7adbe

Browse files
committed
bug fixes
1 parent 3bf58a0 commit 4b7adbe

6 files changed

Lines changed: 36 additions & 19 deletions

File tree

examples/test-service-node-host.js

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -55,27 +55,27 @@ async function main(){
5555

5656
const runner = new Dataparty.ServiceRunnerNode({
5757
party,
58-
prefix: '',
58+
//prefix: 'foo',
5959
service: live,
6060
sendFullErrors: false,
6161
useNative: false
6262
})
63-
64-
await party.start()
65-
await runner.start()
66-
6763

64+
65+
66+
6867
const runnerRouter = new Dataparty.RunnerRouter(runner)
6968

70-
//const srvRouter = new ServiceRouter()
71-
//srvRouter.addRunner(domain, prefix, runner)
72-
69+
7370
const host = new Dataparty.ServiceHost({
7471
runner: runnerRouter,
7572
trust_proxy: true,
7673
wsEnabled: true,
7774
})
78-
75+
76+
debug(runner.party.identity)
77+
await party.start()
78+
await runnerRouter.start()
7979
await host.start()
8080

8181
console.log('started')

src/service/endpoints/service-identity.js

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,6 @@ module.exports = class ServiceIdentity extends IEndpoint {
4343

4444
const identity = ctx.party.identity
4545

46-
return {
47-
...identity
48-
}
46+
return identity.toJSON()
4947
}
5048
}

src/service/runner-router.js

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,18 +12,21 @@ class RunnerRouter {
1212
this.runnersByHost = new Map()
1313

1414
this.started = false
15-
}
1615

16+
}
17+
1718
async start(){
18-
19+
1920
if(this.started){ return }
20-
21+
2122
debug('start')
22-
23+
2324
this.started = true
25+
26+
this.addRunner({runner: this.defaultRunner})
2427

2528
for(let runner of this.runnersByHost){
26-
await runner.start()
29+
await runner[1].start()
2730
}
2831
}
2932

@@ -48,12 +51,12 @@ class RunnerRouter {
4851
const partyId = runner.party.identity.toString()
4952
debug('addRunner - ', partyId, domain)
5053

51-
if(!this.runnersByHost.has(party)){
54+
if(!this.runnersByHost.has(partyId)){
5255
this.runnersByHost.set(partyId, runner)
5356
}
5457

5558

56-
if(domain && !this.runnersByDomain.has(party)){
59+
if(domain && !this.runnersByDomain.has(domain)){
5760
this.runnersByDomain.set(domain, runner)
5861
}
5962
}

src/service/service-host.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,10 +59,16 @@ class ServiceHost {
5959
})
6060
}
6161

62+
this.started = false
63+
6264
}
6365

6466
async start(){
6567

68+
if(this.started){return}
69+
70+
this.started = true
71+
6672
debug('starting server', this.apiServerUri.toString())
6773

6874
if(this.apiServer==null){

src/service/service-runner-node.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,12 +23,17 @@ class ServiceRunnerNode {
2323
this.prefix=prefix
2424
this.router = router
2525
this.taskRunner = new Runner()
26+
27+
this.started = false
2628
}
2729

2830
async start(){
2931

32+
if(this.started){return}
3033
debug('starting tasks')
3134

35+
this.started = true
36+
3237
const taskMap = Hoek.reach(this.service, 'compiled.tasks')
3338
//const endpointsLoading = []
3439
for(let name in taskMap){

src/service/service-runner.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,14 @@ class ServiceRunner {
2323

2424
this.prefix = prefix
2525
this.router = router
26+
this.started = false
2627
}
2728

2829
async start(){
30+
31+
if(this.started){return}
32+
33+
this.started = true
2934
debug('starting endpoints')
3035

3136
const eps = Hoek.reach(this.service, 'compiled.endpoints')

0 commit comments

Comments
 (0)