Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
S
sidecar
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
JIRA
JIRA
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
link33
sidecar
Commits
4818401c
Commit
4818401c
authored
Nov 16, 2021
by
suyanlong
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
update readme.md file and Fixed init bug
parent
9a81dd1d
Pipeline
#8246
canceled with stages
Changes
6
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
95 additions
and
41 deletions
+95
-41
README.md
README.md
+54
-7
start.go
cmd/sidecar/start.go
+5
-2
sidecar.toml
config/sidecar.toml
+20
-12
config.go
internal/repo/config.go
+6
-10
plugin.go
pkg/plugins/plugin.go
+1
-1
start.go
pkg/plugins/start.go
+9
-9
No files found.
README.md
View file @
4818401c
...
@@ -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
=
"
s
idecar"
title
=
"
S
idecar"
[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
...
...
cmd/sidecar/start.go
View file @
4818401c
...
@@ -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
)
...
...
config/sidecar.toml
View file @
4818401c
...
@@ -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/Qm
YwuTi2MCEF39mjK9EnARPjY3RRaapBatqU67znK2c1Nm
","/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/Qm
eRiU3Nh7RDrVjG9XP4tPhVewk3Pa4S63fhHpymSNchoA
","/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
internal/repo/config.go
View file @
4818401c
...
@@ -19,12 +19,12 @@ const (
...
@@ -19,12 +19,12 @@ const (
// Config represents the necessary config data for starting sidecar
// Config represents the necessary config data for starting sidecar
type
Config
struct
{
type
Config
struct
{
RepoRoot
string
RepoRoot
string
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"`
}
}
type
Peer
struct
{
type
Peer
struct
{
...
@@ -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
{
...
...
pkg/plugins/plugin.go
View file @
4818401c
...
@@ -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时,会指明其实现者;
...
...
pkg/plugins/start.go
View file @
4818401c
...
@@ -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,9 +84,11 @@ func CreateClients(appchainConfigs repo.Appchains, extra []byte) []Client {
...
@@ -86,9 +84,11 @@ 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
{
Cmd
:
exec
.
Command
(
"sh"
,
"-c"
,
pluginPath
),
appchainConfig
.
Plugin
:
&
AppchainGRPCPlugin
{},
// 宿主机进程的插件集
Logger
:
logger
,
},
Cmd
:
exec
.
Command
(
"sh"
,
"-c"
,
pluginPath
),
Logger
:
logger
,
AllowedProtocols
:
[]
plugin
.
Protocol
{
AllowedProtocols
:
[]
plugin
.
Protocol
{
plugin
.
ProtocolGRPC
,
plugin
.
ProtocolGRPC
,
},
// 只支持grpc
},
// 只支持grpc
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment