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