Commit 4818401c authored by suyanlong's avatar suyanlong

update readme.md file and Fixed init bug

parent 9a81dd1d
Pipeline #8246 canceled with stages
......@@ -32,29 +32,76 @@ sidecar init --repo=$HOME/sidecar
After initializing sidecar, it will generate the follow directory:
```
~/sidecar
├── sidecar.toml
~/sidecar » tree suyanlong@suyanlongdeMacBook-Pro-2
.
├── api
├── certs
│ └── ca.pem
├── key.json
├── logs
│ ├── sidecar.log -> /Users/suyanlong/sidecar/logs/sidecar.log20211116000000
│ └── sidecar.log20211116000000
├── node.priv
├── plugins
│ ├── chain33
│ │ └── chain33.toml
│ └── chain33-client
├── pprof
│ ├── cpu-20211116-10:53:17
│ ├── cpu-20211116-11:04:56
│ ├── mem-20211116-10:53:17
│ └── mem-20211116-11:04:56
├── sidecar.toml
└── store
├── 000074.log
├── CURRENT
├── CURRENT.bak
├── LOCK
├── LOG
└── MANIFEST-000075
```
## Configuration
```toml
title = "sidecar"
title = "Sidecar"
[port]
http = 44544
pprof = 44555
[log]
level = "debug"
level = "info"
dir = "logs"
filename = "sidecar.log"
report_caller = false
[appchain]
plugin = "fabric-client-1.4.so"
config = "fabric"
[log.module]
api_server = "info"
appchain_mgr = "info"
bxh_lite = "info"
executor = "info"
exchanger = "info"
monitor = "info"
peer_mgr = "info"
router = "info"
rule_mgr = "info"
swarm = "info"
syncer = "info"
[[appchains]]
enable = true
type = "appchain"
did = "did:bitxhub:chain33:."
plugin = "chain33-client"
config = "chain33"
[peer]
peers = ["/ip4/127.0.0.1/tcp/4000/p2p/QmeRiU3Nh7RDrVjG9XP4tPhVewk3Pa4S63fhHpymSNchoA","/ip4/127.0.0.1/tcp/4001/ipfs/QmfC33rPPobCDo1WBhAy8VG6ocTiLfZzFb8aaQGqv3MVv3","/ip4/127.0.0.1/tcp/4002/ipfs/QmVtRucwZjzLb2AEd4CRZ2nheLrDEuUymG8zKsfxdg2pic"]
connectors = ["localhost:60011", "localhost:60012", "localhost:60013", "localhost:60014"]
providers = 1
```
`port.pprof`: the pprof server port
......
......@@ -59,7 +59,8 @@ func start(ctx *cli.Context) error {
loggers.InitializeLogger(config)
var sidecar internal.Launcher
fmt.Println(repoRoot)
fmt.Println(config)
sidecar, err = app.NewSidecar(repoRoot, config)
if err != nil {
return err
......@@ -114,7 +115,9 @@ func httpPProf(port int64) {
// runtimePProf will record the cpu or memory profiles every 5 second.
func runtimePProf() {
tick := time.NewTicker(time.Second * 5)
rootPath := filepath.Join(repo.DefaultPathRoot, "/pprof/")
defaultPathRoot, err := repo.PathRoot()
tool.Asset(err)
rootPath := filepath.Join(defaultPathRoot, "/pprof/")
exist := tool.Exist(rootPath)
if !exist {
err := os.Mkdir(rootPath, os.ModePerm)
......
......@@ -9,18 +9,19 @@ level = "info"
dir = "logs"
filename = "sidecar.log"
report_caller = false
[log.module]
api_server = "info"
appchain_mgr = "info"
bxh_lite = "info"
executor = "info"
exchanger = "info"
monitor = "info"
peer_mgr = "info"
router = "info"
rule_mgr = "info"
swarm = "info"
syncer = "info"
api_server = "info"
appchain_mgr = "info"
bxh_lite = "info"
executor = "info"
exchanger = "info"
monitor = "info"
peer_mgr = "info"
router = "info"
rule_mgr = "info"
swarm = "info"
syncer = "info"
#[hub]
#enable = true
......@@ -49,8 +50,15 @@ report_caller = false
#plugin = "appchain_plugin"
#config = "chain33"
[[appchains]]
enable = true
type = "appchain"
did = "did:bitxhub:chain33:."
plugin = "chain33-client"
config = "chain33"
[peer]
peers = ["/ip4/127.0.0.1/tcp/4000/p2p/QmYwuTi2MCEF39mjK9EnARPjY3RRaapBatqU67znK2c1Nm","/ip4/127.0.0.1/tcp/4001/ipfs/QmfC33rPPobCDo1WBhAy8VG6ocTiLfZzFb8aaQGqv3MVv3","/ip4/127.0.0.1/tcp/4002/ipfs/QmVtRucwZjzLb2AEd4CRZ2nheLrDEuUymG8zKsfxdg2pic"]
peers = ["/ip4/127.0.0.1/tcp/4000/p2p/QmeRiU3Nh7RDrVjG9XP4tPhVewk3Pa4S63fhHpymSNchoA","/ip4/127.0.0.1/tcp/4001/ipfs/QmfC33rPPobCDo1WBhAy8VG6ocTiLfZzFb8aaQGqv3MVv3","/ip4/127.0.0.1/tcp/4002/ipfs/QmVtRucwZjzLb2AEd4CRZ2nheLrDEuUymG8zKsfxdg2pic"]
connectors = ["localhost:60011", "localhost:60012", "localhost:60013", "localhost:60014"]
providers = 1
......@@ -22,7 +22,7 @@ type Config struct {
Title string `toml:"title" json:"title"`
Port Port `toml:"port" json:"port"`
Log Log `toml:"log" json:"log"`
Appchains Appchains `toml:"appchains" json:"appchains"`
Appchains []Appchain `toml:"appchains" json:"appchains"`
Security Security `toml:"security" json:"security"`
Peer Peer `toml:"peer" json:"peer"`
}
......@@ -79,10 +79,6 @@ type Appchain struct {
Plugin string `toml:"plugin" json:"plugin"`
}
type Appchains struct {
Appchains []Appchain
}
// DefaultConfig returns config with default value
func DefaultConfig() *Config {
return &Config{
......
......@@ -16,7 +16,7 @@ var (
MagicCookieKey: "SIDECAR_APPCHAIN_PLUGIN",
MagicCookieValue: "SIDECAR",
}
PluginName = "appchain-plugin"
PluginName = "chain33-client"
)
// 插件进程在启动时设置Plugins,即ServeConfig中设置Plugins时,会指明其实现者;
......
......@@ -67,15 +67,13 @@ func CreateClient(sidecarID string, appchainConfig repo.Appchain, extra []byte)
return appchain, client, nil
}
func CreateClients(appchainConfigs repo.Appchains, extra []byte) []Client {
func CreateClients(appchainConfigs []repo.Appchain, extra []byte) []Client {
// Sidecar is the host. Start by launching the plugin process.
rootPath, err := repo.PathRoot()
if err != nil {
panic(err)
}
tool.Asset(err)
var clients []Client
for _, appchainConfig := range appchainConfigs.Appchains {
pluginConfigPath := filepath.Join(rootPath, appchainConfig.Config)
for _, appchainConfig := range appchainConfigs {
pluginConfigPath := filepath.Join(rootPath, "plugins", appchainConfig.Config)
pluginPath := filepath.Join(rootPath, "plugins", appchainConfig.Plugin)
_, err = os.Stat(pluginPath)
if err != nil {
......@@ -86,7 +84,9 @@ func CreateClients(appchainConfigs repo.Appchains, extra []byte) []Client {
}
kernel := plugin.NewClient(&plugin.ClientConfig{
HandshakeConfig: Handshake,
Plugins: PluginMap,
Plugins: map[string]plugin.Plugin{
appchainConfig.Plugin: &AppchainGRPCPlugin{}, // 宿主机进程的插件集
},
Cmd: exec.Command("sh", "-c", pluginPath),
Logger: logger,
AllowedProtocols: []plugin.Protocol{
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment