Compare commits
2 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| f33d0a54c4 | |||
| 899ca015b1 |
@@ -218,7 +218,7 @@ func runDaemon(ctx context.Context, daemArgs *daemonArgs, configFile *string) fu
|
||||
}
|
||||
}()
|
||||
|
||||
poller := poll.New(ctx, cfg, cli, runner)
|
||||
poller := poll.New(cfg, cli, runner)
|
||||
poller.SetBandwidthManager(bandwidthManager)
|
||||
|
||||
if daemArgs.Once || reg.Ephemeral {
|
||||
|
||||
@@ -40,11 +40,11 @@ type Poller struct {
|
||||
done chan struct{}
|
||||
}
|
||||
|
||||
// New creates a new Poller instance with the given context for shutdown propagation.
|
||||
func New(ctx context.Context, cfg *config.Config, client client.Client, runner *run.Runner) *Poller {
|
||||
// Inherit from parent context so shutdown signals propagate properly
|
||||
pollingCtx, shutdownPolling := context.WithCancel(ctx)
|
||||
jobsCtx, shutdownJobs := context.WithCancel(ctx)
|
||||
// New creates a new Poller instance.
|
||||
func New(cfg *config.Config, client client.Client, runner *run.Runner) *Poller {
|
||||
// Use independent contexts - shutdown is handled explicitly via Shutdown()
|
||||
pollingCtx, shutdownPolling := context.WithCancel(context.Background())
|
||||
jobsCtx, shutdownJobs := context.WithCancel(context.Background())
|
||||
|
||||
done := make(chan struct{})
|
||||
|
||||
|
||||
@@ -8,7 +8,6 @@ import (
|
||||
"crypto/tls"
|
||||
"net/http"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"code.gitea.io/actions-proto-go/ping/v1/pingv1connect"
|
||||
"code.gitea.io/actions-proto-go/runner/v1/runnerv1connect"
|
||||
@@ -16,24 +15,16 @@ import (
|
||||
)
|
||||
|
||||
func getHTTPClient(endpoint string, insecure bool) *http.Client {
|
||||
transport := &http.Transport{
|
||||
MaxIdleConns: 10,
|
||||
MaxIdleConnsPerHost: 5,
|
||||
IdleConnTimeout: 90 * time.Second,
|
||||
TLSHandshakeTimeout: 10 * time.Second,
|
||||
DisableKeepAlives: false,
|
||||
}
|
||||
|
||||
if strings.HasPrefix(endpoint, "https://") && insecure {
|
||||
transport.TLSClientConfig = &tls.Config{
|
||||
InsecureSkipVerify: true,
|
||||
return &http.Client{
|
||||
Transport: &http.Transport{
|
||||
TLSClientConfig: &tls.Config{
|
||||
InsecureSkipVerify: true,
|
||||
},
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
return &http.Client{
|
||||
Transport: transport,
|
||||
Timeout: 30 * time.Second,
|
||||
}
|
||||
return http.DefaultClient
|
||||
}
|
||||
|
||||
// New returns a new runner client.
|
||||
|
||||
@@ -190,20 +190,10 @@ func (r *Reporter) RunDaemon() {
|
||||
return
|
||||
}
|
||||
|
||||
if err := r.ReportLog(false); err != nil {
|
||||
log.WithError(err).Warn("failed to report log")
|
||||
}
|
||||
if err := r.ReportState(); err != nil {
|
||||
log.WithError(err).Warn("failed to report state")
|
||||
}
|
||||
_ = r.ReportLog(false)
|
||||
_ = r.ReportState()
|
||||
|
||||
// Use select with context to allow clean shutdown
|
||||
select {
|
||||
case <-r.ctx.Done():
|
||||
return
|
||||
case <-time.After(time.Second):
|
||||
r.RunDaemon()
|
||||
}
|
||||
time.AfterFunc(time.Second, r.RunDaemon)
|
||||
}
|
||||
|
||||
// Logf adds a formatted log message to the report.
|
||||
|
||||
Reference in New Issue
Block a user