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
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
88 additions
and
34 deletions
+88
-34
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
+1
-5
plugin.go
pkg/plugins/plugin.go
+1
-1
start.go
pkg/plugins/start.go
+7
-7
No files found.
README.md
View file @
4818401c
...
...
@@ -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
=
"
s
idecar"
title
=
"
S
idecar"
[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
...
...
cmd/sidecar/start.go
View file @
4818401c
...
...
@@ -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
)
...
...
config/sidecar.toml
View file @
4818401c
...
...
@@ -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/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"
]
providers
=
1
internal/repo/config.go
View file @
4818401c
...
...
@@ -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
{
...
...
pkg/plugins/plugin.go
View file @
4818401c
...
...
@@ -16,7 +16,7 @@ var (
MagicCookieKey
:
"SIDECAR_APPCHAIN_PLUGIN"
,
MagicCookieValue
:
"SIDECAR"
,
}
PluginName
=
"
appchain-plugin
"
PluginName
=
"
chain33-client
"
)
// 插件进程在启动时设置Plugins,即ServeConfig中设置Plugins时,会指明其实现者;
...
...
pkg/plugins/start.go
View file @
4818401c
...
...
@@ -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
{
...
...
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