This repository has been archived by the owner on Sep 14, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
initialisation.go
71 lines (58 loc) · 1.71 KB
/
initialisation.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
// Copyright (c) 2014-2015 Bitmark Inc.
// Use of this source code is governed by an ISC
// license that can be found in the LICENSE file
package main
import (
"github.com/bitmark-inc/bitmark-webgui/api"
"github.com/bitmark-inc/bitmark-webgui/configuration"
"github.com/bitmark-inc/bitmark-webgui/services"
"github.com/bitmark-inc/bitmarkd/background"
)
var backgroundService *background.T
var bitcoinService services.Bitcoind
var bitmarkService services.Bitmarkd
var prooferdService services.Prooferd
var bitmarkConsoleService services.BitmarkConsole
// start service
func InitialiseService(configs *configuration.Configuration) error {
// initialise all services
// if err := bitcoinService.Initialise(); nil != err {
// return err
// }
if err := bitmarkService.Initialise(configs.BitmarkConfigFile); nil != err {
return err
}
if err := prooferdService.Initialise(configs.ProoferdConfigFile); nil != err {
return err
}
if err := bitmarkConsoleService.Initialise(configs.BitmarkConsoleBin); nil != err {
return err
}
// create and start all background service
var processes = background.Processes{
// &bitcoinService,
&bitmarkService,
&prooferdService,
}
backgroundService = background.Start(processes, nil)
// register services to api
// api.Register(&bitcoinService)
api.Register(&bitmarkService)
api.Register(&prooferdService)
return nil
}
// finialise - stop all background tasks
func FinaliseBackgroundService() error {
if err := bitcoinService.Finalise(); nil != err {
return err
}
if err := bitmarkService.Finalise(); nil != err {
return err
}
if err := bitmarkConsoleService.Finalise(); nil != err {
return err
}
// stop backgrond services
backgroundService.Stop()
return nil
}