chore(proto): Add ping request.

Signed-off-by: Bo-Yi Wu <appleboy.tw@gmail.com>
This commit is contained in:
Bo-Yi Wu
2022-08-13 22:41:01 +08:00
committed by Jason Song
parent 14a345504f
commit 4d7ef95d40
8 changed files with 179 additions and 7 deletions

View File

@@ -4,6 +4,7 @@ import (
"context"
"time"
"gitea.com/gitea/act_runner/client"
"gitea.com/gitea/act_runner/engine"
"github.com/joho/godotenv"
@@ -164,7 +165,33 @@ func runDaemon(ctx context.Context, input *Input) func(cmd *cobra.Command, args
}
time.Sleep(time.Second)
} else {
log.Debugln("successfully pinged the docker daemon")
log.Infoln("successfully pinged the docker daemon")
break
}
}
cli := client.New(
cfg.Client.Address,
cfg.Client.Secret,
cfg.Client.SkipVerify,
)
for {
err := cli.Ping(ctx, cfg.Runner.Name)
select {
case <-ctx.Done():
return nil
default:
}
if ctx.Err() != nil {
break
}
if err != nil {
log.WithError(err).
Errorln("cannot ping the remote server")
time.Sleep(time.Second)
} else {
log.Infoln("successfully pinged the remote server")
break
}
}