mirror of
https://gitea.com/gitea/act_runner.git
synced 2025-06-13 01:57:13 +02:00
chore(poller): Add poller package
Signed-off-by: Bo-Yi Wu <appleboy.tw@gmail.com>
This commit is contained in:
@ -29,6 +29,13 @@ type (
|
||||
Environ map[string]string `envconfig:"GITEA_RUNNER_ENVIRON"`
|
||||
EnvFile string `envconfig:"GITEA_RUNNER_ENV_FILE"`
|
||||
}
|
||||
|
||||
Platform struct {
|
||||
OS string `envconfig:"GITEA_PLATFORM_OS" default:"linux"`
|
||||
Arch string `envconfig:"GITEA_PLATFORM_ARCH" default:"amd64"`
|
||||
Kernel string `envconfig:"GITEA_PLATFORM_KERNEL"`
|
||||
Variant string `envconfig:"GITEA_PLATFORM_VARIANT"`
|
||||
}
|
||||
}
|
||||
)
|
||||
|
||||
|
24
cmd/damon.go
24
cmd/damon.go
@ -6,6 +6,8 @@ import (
|
||||
|
||||
"gitea.com/gitea/act_runner/client"
|
||||
"gitea.com/gitea/act_runner/engine"
|
||||
"gitea.com/gitea/act_runner/poller"
|
||||
"golang.org/x/sync/errgroup"
|
||||
|
||||
"github.com/joho/godotenv"
|
||||
log "github.com/sirupsen/logrus"
|
||||
@ -196,7 +198,27 @@ func runDaemon(ctx context.Context, input *Input) func(cmd *cobra.Command, args
|
||||
}
|
||||
}
|
||||
|
||||
return nil
|
||||
var g errgroup.Group
|
||||
|
||||
poller := poller.New(cli)
|
||||
|
||||
g.Go(func() error {
|
||||
log.WithField("capacity", cfg.Runner.Capacity).
|
||||
WithField("endpoint", cfg.Client.Address).
|
||||
WithField("os", cfg.Platform.OS).
|
||||
WithField("arch", cfg.Platform.Arch).
|
||||
Infoln("polling the remote server")
|
||||
|
||||
poller.Poll(ctx, cfg.Runner.Capacity)
|
||||
return nil
|
||||
})
|
||||
|
||||
err = g.Wait()
|
||||
if err != nil {
|
||||
log.WithError(err).
|
||||
Errorln("shutting down the server")
|
||||
}
|
||||
return err
|
||||
// var conn *websocket.Conn
|
||||
// var err error
|
||||
// ticker := time.NewTicker(time.Second)
|
||||
|
Reference in New Issue
Block a user