Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' of github.com:didi/nightingale
- Loading branch information
Showing
8 changed files
with
157 additions
and
72 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,11 @@ | ||
FROM golang AS builder | ||
# RUN apk add --no-cache git gcc | ||
WORKDIR /app | ||
|
||
COPY . . | ||
RUN ./control build docker | ||
FROM golang:1.13 | ||
|
||
FROM buildpack-deps:buster-curl | ||
LABEL maintainer="llitfkitfk@gmail.com" | ||
LABEL maintainer="llitfkitfk@gmail.com,chenjiandongx@qq.com" | ||
|
||
WORKDIR /app | ||
|
||
COPY --from=builder /app/docker/scripts /app/scripts | ||
COPY --from=builder /app/etc /app/etc | ||
# Change default address (hard code) | ||
RUN ./scripts/sed.sh | ||
RUN apt-get update && apt-get install net-tools -y | ||
|
||
COPY --from=builder /app/bin /usr/local/bin | ||
|
||
|
||
# ENTRYPOINT [] | ||
# CMD [] | ||
COPY . . | ||
RUN ./control build docker | ||
RUN mv /app/bin/* /usr/local/bin |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -73,6 +73,7 @@ func main() { | |
|
||
funcs.BuildMappers() | ||
funcs.Collect() | ||
funcs.InitRpcClients() | ||
|
||
//插件采集 | ||
plugins.Detect() | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
package funcs | ||
|
||
import ( | ||
"net/rpc" | ||
"sync" | ||
) | ||
|
||
type RpcClientContainer struct { | ||
M map[string]*rpc.Client | ||
sync.RWMutex | ||
} | ||
|
||
var rpcClients *RpcClientContainer | ||
|
||
func InitRpcClients() { | ||
rpcClients = &RpcClientContainer{ | ||
M: make(map[string]*rpc.Client), | ||
} | ||
} | ||
|
||
func (rcc *RpcClientContainer) Get(addr string) *rpc.Client { | ||
rcc.RLock() | ||
defer rcc.RUnlock() | ||
|
||
client, has := rcc.M[addr] | ||
if !has { | ||
return nil | ||
} | ||
|
||
return client | ||
} | ||
|
||
// Put 返回的bool表示affected,确实把自己塞进去了 | ||
func (rcc *RpcClientContainer) Put(addr string, client *rpc.Client) bool { | ||
rcc.Lock() | ||
defer rcc.Unlock() | ||
|
||
oc, has := rcc.M[addr] | ||
if has && oc != nil { | ||
return false | ||
} | ||
|
||
rcc.M[addr] = client | ||
return true | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters