mirror of
https://github.com/woodpecker-ci/woodpecker.git
synced 2024-12-26 10:20:29 +00:00
Add keepalive to agents
This commit is contained in:
parent
e582c20812
commit
06fa27d937
2 changed files with 32 additions and 0 deletions
|
@ -12,6 +12,7 @@ import (
|
|||
"time"
|
||||
|
||||
"google.golang.org/grpc"
|
||||
"google.golang.org/grpc/keepalive"
|
||||
"google.golang.org/grpc/metadata"
|
||||
|
||||
"github.com/cncd/pipeline/pipeline"
|
||||
|
@ -68,6 +69,26 @@ func loop(c *cli.Context) error {
|
|||
|
||||
// grpc.Dial(target, ))
|
||||
|
||||
agentKeepalive := keepalive.ClientParameters{}
|
||||
if c.String("keepalive-time") != "" {
|
||||
d, err := time.ParseDuration(c.String("keepalive-time"))
|
||||
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
agentKeepalive.Time = d
|
||||
}
|
||||
if c.String("keepalive-timeout") != "" {
|
||||
d, err := time.ParseDuration(c.String("keepalive-timeout"))
|
||||
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
agentKeepalive.Timeout = d
|
||||
}
|
||||
|
||||
conn, err := grpc.Dial(
|
||||
c.String("server"),
|
||||
grpc.WithInsecure(),
|
||||
|
@ -75,6 +96,7 @@ func loop(c *cli.Context) error {
|
|||
username: c.String("username"),
|
||||
password: c.String("password"),
|
||||
}),
|
||||
grpc.WithKeepaliveParams(agentKeepalive),
|
||||
)
|
||||
|
||||
if err != nil {
|
||||
|
|
|
@ -80,6 +80,16 @@ func main() {
|
|||
Name: "healthcheck",
|
||||
Usage: "enables the healthcheck endpoint",
|
||||
},
|
||||
cli.StringFlag{
|
||||
EnvVar: "DRONE_KEEPALIVE_TIME",
|
||||
Name: "keepalive-time",
|
||||
Usage: "after a duration of this time if the agent doesn't see any activity it pings the server to see if the transport is still alive",
|
||||
},
|
||||
cli.StringFlag{
|
||||
EnvVar: "DRONE_KEEPALIVE_TIMEOUT",
|
||||
Name: "keepalive-timeout",
|
||||
Usage: "after having pinged for keepalive check, the client waits for a duration of Timeout and if no activity is seen even after that the connection is closed.",
|
||||
},
|
||||
}
|
||||
|
||||
if err := app.Run(os.Args); err != nil {
|
||||
|
|
Loading…
Reference in a new issue