Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
goSDN
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Terraform modules
Analyze
Contributor analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
danet
goSDN
Commits
9e2b2d61
Commit
9e2b2d61
authored
4 years ago
by
Malte Bauch
Browse files
Options
Downloads
Patches
Plain Diff
logging in tview working
parent
30364212
Branches
Branches containing commit
Tags
Tags containing commit
3 merge requests
!90
Develop
,
!69
Resolve "Stream logger-output to goSDN-tview via gRPC"
,
!53
V.0.1.0 Codename Threadbare
Pipeline
#53087
passed
4 years ago
Stage: test
Stage: deploy
This commit is part of merge request
!53
. Comments created here will be created in the context of that merge request.
Changes
2
Pipelines
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
cmd/gosdn-tview/grpc/commands.go
+1
-1
1 addition, 1 deletion
cmd/gosdn-tview/grpc/commands.go
nucleus/cli-handling.go
+20
-11
20 additions, 11 deletions
nucleus/cli-handling.go
with
21 additions
and
12 deletions
cmd/gosdn-tview/grpc/commands.go
+
1
−
1
Edit
View file @
9e2b2d61
...
@@ -32,7 +32,7 @@ var CommandList = []command{
...
@@ -32,7 +32,7 @@ var CommandList = []command{
//Connect creates a new connection to the gRPC server
//Connect creates a new connection to the gRPC server
func
Connect
()
(
*
grpc
.
ClientConn
,
error
)
{
func
Connect
()
(
*
grpc
.
ClientConn
,
error
)
{
address
:=
"
localhost
:550
55
"
address
:=
"
141.100.70.170
:550
66
"
return
grpc
.
Dial
(
address
,
grpc
.
WithInsecure
(),
grpc
.
WithTimeout
(
5
*
time
.
Second
),
grpc
.
WithBlock
())
return
grpc
.
Dial
(
address
,
grpc
.
WithInsecure
(),
grpc
.
WithTimeout
(
5
*
time
.
Second
),
grpc
.
WithBlock
())
}
}
...
...
This diff is collapsed.
Click to expand it.
nucleus/cli-handling.go
+
20
−
11
Edit
View file @
9e2b2d61
...
@@ -8,9 +8,10 @@ package nucleus
...
@@ -8,9 +8,10 @@ package nucleus
import
(
import
(
"context"
"context"
"io"
"net"
"net"
"os"
"sync"
"sync"
"time"
pb
"code.fbi.h-da.de/cocsn/gosdn/api/proto"
pb
"code.fbi.h-da.de/cocsn/gosdn/api/proto"
"code.fbi.h-da.de/cocsn/gosdn/log"
"code.fbi.h-da.de/cocsn/gosdn/log"
...
@@ -33,6 +34,17 @@ type server struct {
...
@@ -33,6 +34,17 @@ type server struct {
logConnections
[]
*
LogConnection
logConnections
[]
*
LogConnection
}
}
var
srv
*
server
type
buf
[]
byte
func
(
b
*
buf
)
Write
(
p
[]
byte
)
(
n
int
,
err
error
)
{
reply
:=
pb
.
LogReply
{
Log
:
string
(
p
)}
srv
.
BroadcastLog
(
&
reply
)
return
len
(
p
),
nil
}
func
(
s
*
server
)
SayHello
(
ctx
context
.
Context
,
in
*
pb
.
HelloRequest
)
(
*
pb
.
HelloReply
,
error
)
{
func
(
s
*
server
)
SayHello
(
ctx
context
.
Context
,
in
*
pb
.
HelloRequest
)
(
*
pb
.
HelloReply
,
error
)
{
log
.
Info
(
"Received: "
,
in
.
GetName
())
log
.
Info
(
"Received: "
,
in
.
GetName
())
return
&
pb
.
HelloReply
{
Message
:
"Hello "
+
in
.
GetName
(),
GoSDNInfo
:
"goSDN in version: DEVELOP"
},
nil
return
&
pb
.
HelloReply
{
Message
:
"Hello "
+
in
.
GetName
(),
GoSDNInfo
:
"goSDN in version: DEVELOP"
},
nil
...
@@ -88,6 +100,8 @@ func (s *server) Shutdown(ctx context.Context, in *pb.ShutdownRequest) (*pb.Shut
...
@@ -88,6 +100,8 @@ func (s *server) Shutdown(ctx context.Context, in *pb.ShutdownRequest) (*pb.Shut
func
getCLIGoing
(
core
*
Core
)
{
func
getCLIGoing
(
core
*
Core
)
{
var
logConnections
[]
*
LogConnection
var
logConnections
[]
*
LogConnection
var
logBuffer
buf
log
.
Info
(
"Starting: GetCLIGoing"
)
log
.
Info
(
"Starting: GetCLIGoing"
)
// Boot-up the control interface for the cli
// Boot-up the control interface for the cli
cliControlListener
,
err
:=
net
.
Listen
(
"tcp"
,
core
.
config
.
CliSocket
)
cliControlListener
,
err
:=
net
.
Listen
(
"tcp"
,
core
.
config
.
CliSocket
)
...
@@ -96,18 +110,13 @@ func getCLIGoing(core *Core) {
...
@@ -96,18 +110,13 @@ func getCLIGoing(core *Core) {
}
}
cliControlServer
:=
grpc
.
NewServer
()
cliControlServer
:=
grpc
.
NewServer
()
s
e
rv
er
:
=
&
server
{
core
:
core
,
logConnections
:
logConnections
}
srv
=
&
server
{
core
:
core
,
logConnections
:
logConnections
}
pb
.
RegisterGrpcCliServer
(
cliControlServer
,
server
)
//TODO: move?
wrt
:=
io
.
MultiWriter
(
os
.
Stdout
,
&
logBuffer
)
log
.
Output
(
wrt
)
//TODO: remove!
pb
.
RegisterGrpcCliServer
(
cliControlServer
,
srv
)
go
func
()
{
ticker
:=
time
.
NewTicker
(
5
*
time
.
Second
)
for
t
:=
range
ticker
.
C
{
reply
:=
pb
.
LogReply
{
Log
:
t
.
String
()}
server
.
BroadcastLog
(
&
reply
)
}
}()
if
err
:=
cliControlServer
.
Serve
(
cliControlListener
);
err
!=
nil
{
if
err
:=
cliControlServer
.
Serve
(
cliControlListener
);
err
!=
nil
{
log
.
Fatal
(
err
)
log
.
Fatal
(
err
)
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment