Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
R
replds
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
2
Issues
2
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Packages & Registries
Packages & Registries
Container Registry
Analytics
Analytics
CI / CD
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
ai3
tools
replds
Commits
1b52bb36
Commit
1b52bb36
authored
Aug 29, 2019
by
ale
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Disable HTTP server for readonly instances
parent
36012c94
Pipeline
#4273
passed with stages
in 1 minute and 44 seconds
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
23 additions
and
6 deletions
+23
-6
cmd/replds/server.go
cmd/replds/server.go
+16
-5
server.go
server.go
+7
-1
No files found.
cmd/replds/server.go
View file @
1b52bb36
...
...
@@ -4,6 +4,9 @@ import (
"context"
"flag"
"log"
"os"
"os/signal"
"syscall"
"git.autistici.org/ai3/go-common/serverutil"
"github.com/google/subcommands"
...
...
@@ -56,12 +59,20 @@ func (c *serverCmd) Execute(_ context.Context, f *flag.FlagSet, _ ...interface{}
}
defer
srv
.
Close
()
httpSrv
:=
replds
.
NewHTTPServer
(
srv
)
// If this is a readonly server, just wait for a termination
// signal, otherwise start the HTTP server for our API.
if
config
.
Server
.
Readonly
{
sigCh
:=
make
(
chan
os
.
Signal
)
signal
.
Notify
(
sigCh
,
syscall
.
SIGINT
,
syscall
.
SIGTERM
)
<-
sigCh
}
else
{
httpSrv
:=
replds
.
NewHTTPServer
(
srv
)
log
.
Printf
(
"starting replds on %s"
,
config
.
Server
.
Addr
)
if
err
:=
serverutil
.
Serve
(
httpSrv
.
Handler
(),
config
.
HTTPServer
,
config
.
Server
.
Addr
);
err
!=
nil
{
log
.
Printf
(
"error: %v"
,
err
)
return
subcommands
.
ExitFailure
log
.
Printf
(
"starting replds on %s"
,
config
.
Server
.
Addr
)
if
err
:=
serverutil
.
Serve
(
httpSrv
.
Handler
(),
config
.
HTTPServer
,
config
.
Server
.
Addr
);
err
!=
nil
{
log
.
Printf
(
"error: %v"
,
err
)
return
subcommands
.
ExitFailure
}
}
return
subcommands
.
ExitSuccess
...
...
server.go
View file @
1b52bb36
...
...
@@ -214,7 +214,9 @@ func (s *Server) doSetNodes(ctx context.Context, nodes []*Node, updatePeers bool
var
res
SetNodesResponse
if
updatePeers
{
// Ping remote nodes with updated state.
// Ping remote nodes with the updated state. This
// reduces the latency of update propagation (we don't
// have to wait until the peers poll us).
res
.
HostsOk
=
1
for
_
,
peer
:=
range
s
.
peers
{
err
:=
s
.
network
.
Client
(
peer
)
.
internalUpdateNodes
(
ctx
,
&
internalUpdateNodesRequest
{
...
...
@@ -419,6 +421,9 @@ func (s *Server) pollPeerRequest(peer string) (bool, error) {
peerName
:=
stripHTTP
(
peer
)
peerRequests
.
With
(
prometheus
.
Labels
{
"peer"
:
peerName
})
.
Inc
()
// Create a shallow copy of the list of the Nodes we know
// about, containing just path/timestamp, to send to the peer
// in our GetNodes request.
s
.
mx
.
Lock
()
var
req
internalGetNodesRequest
for
_
,
node
:=
range
s
.
nodes
{
...
...
@@ -443,6 +448,7 @@ func (s *Server) pollPeerRequest(peer string) (bool, error) {
return
false
,
nil
}
// Update the internal state with the new data.
return
resp
.
Partial
,
s
.
internalUpdateNodes
(
ctx
,
&
internalUpdateNodesRequest
{
Nodes
:
resp
.
Nodes
})
}
...
...
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