mirror of
https://gitea.com/gitea/act_runner.git
synced 2025-06-13 01:57:13 +02:00
chore(runner): remove update runner status
Signed-off-by: Bo-Yi.Wu <appleboy.tw@gmail.com>
This commit is contained in:
34
cmd/cmd.go
34
cmd/cmd.go
@ -3,12 +3,7 @@ package cmd
|
||||
import (
|
||||
"context"
|
||||
"os"
|
||||
"strconv"
|
||||
|
||||
"gitea.com/gitea/act_runner/engine"
|
||||
"gitea.com/gitea/act_runner/runtime"
|
||||
|
||||
log "github.com/sirupsen/logrus"
|
||||
"github.com/spf13/cobra"
|
||||
)
|
||||
|
||||
@ -25,16 +20,12 @@ func Execute(ctx context.Context) {
|
||||
|
||||
// ./act_runner
|
||||
rootCmd := &cobra.Command{
|
||||
Use: "act [event name to run]\nIf no event name passed, will default to \"on: push\"",
|
||||
Short: "Run GitHub actions locally by specifying the event name (e.g. `push`) or an action name directly.",
|
||||
Args: cobra.MaximumNArgs(1),
|
||||
// RunE: runRoot(ctx, task),
|
||||
Use: "act [event name to run]\nIf no event name passed, will default to \"on: push\"",
|
||||
Short: "Run GitHub actions locally by specifying the event name (e.g. `push`) or an action name directly.",
|
||||
Args: cobra.MaximumNArgs(1),
|
||||
Version: version,
|
||||
SilenceUsage: true,
|
||||
}
|
||||
//rootCmd.Flags().BoolP("run", "r", false, "run workflows")
|
||||
//rootCmd.Flags().StringP("job", "j", "", "run job")
|
||||
//rootCmd.PersistentFlags().StringVarP(&task.Input.ForgeInstance, "forge-instance", "", "github.com", "Forge instance to use.")
|
||||
rootCmd.PersistentFlags().StringVarP(&gArgs.EnvFile, "env-file", "", ".env", "Read in a file of environment variables.")
|
||||
|
||||
// ./act_runner register
|
||||
@ -69,22 +60,3 @@ func Execute(ctx context.Context) {
|
||||
os.Exit(1)
|
||||
}
|
||||
}
|
||||
|
||||
func runRoot(ctx context.Context, task *runtime.Task) func(cmd *cobra.Command, args []string) error {
|
||||
return func(cmd *cobra.Command, args []string) error {
|
||||
jobID, err := cmd.Flags().GetString("job")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
// try to connect to docker daemon
|
||||
// if failed, exit with error
|
||||
if err := engine.Start(ctx); err != nil {
|
||||
log.WithError(err).Fatalln("failed to connect docker daemon engine")
|
||||
}
|
||||
|
||||
task.BuildID, _ = strconv.ParseInt(jobID, 10, 64)
|
||||
_ = task.Run(ctx, nil)
|
||||
return nil
|
||||
}
|
||||
}
|
||||
|
@ -9,9 +9,7 @@ import (
|
||||
"gitea.com/gitea/act_runner/engine"
|
||||
"gitea.com/gitea/act_runner/poller"
|
||||
"gitea.com/gitea/act_runner/runtime"
|
||||
runnerv1 "gitea.com/gitea/proto-go/runner/v1"
|
||||
|
||||
"github.com/bufbuild/connect-go"
|
||||
"github.com/joho/godotenv"
|
||||
"github.com/mattn/go-isatty"
|
||||
log "github.com/sirupsen/logrus"
|
||||
@ -63,41 +61,17 @@ func runDaemon(ctx context.Context, envFile string) func(cmd *cobra.Command, arg
|
||||
)
|
||||
|
||||
g.Go(func() error {
|
||||
log.WithField("capacity", cfg.Runner.Capacity).
|
||||
l := 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")
|
||||
WithField("arch", cfg.Platform.Arch)
|
||||
l.Infoln("polling the remote server")
|
||||
|
||||
// update runner status to idle
|
||||
log.Infoln("update runner status to idle")
|
||||
if _, err := cli.UpdateRunner(
|
||||
context.Background(),
|
||||
connect.NewRequest(&runnerv1.UpdateRunnerRequest{
|
||||
Status: runnerv1.RunnerStatus_RUNNER_STATUS_IDLE,
|
||||
}),
|
||||
); err != nil {
|
||||
// go on, if return err, the program will be stuck
|
||||
log.WithError(err).
|
||||
Errorln("failed to update runner")
|
||||
if err := poller.Poll(ctx); err != nil {
|
||||
l.Errorf("poller error: %v", err)
|
||||
}
|
||||
|
||||
return poller.Poll(ctx)
|
||||
})
|
||||
|
||||
g.Go(func() error {
|
||||
// wait all workflows done.
|
||||
poller.Wait()
|
||||
// received the shutdown signal
|
||||
<-ctx.Done()
|
||||
log.Infoln("update runner status to offline")
|
||||
_, err := cli.UpdateRunner(
|
||||
context.Background(),
|
||||
connect.NewRequest(&runnerv1.UpdateRunnerRequest{
|
||||
Status: runnerv1.RunnerStatus_RUNNER_STATUS_OFFLINE,
|
||||
}),
|
||||
)
|
||||
return err
|
||||
return nil
|
||||
})
|
||||
|
||||
err = g.Wait()
|
||||
|
@ -105,7 +105,6 @@ func (r *registerInputs) validate() error {
|
||||
}
|
||||
|
||||
func (r *registerInputs) assignToNext(stage registerStage, value string) registerStage {
|
||||
|
||||
// must set instance address and token.
|
||||
// if empty, keep current stage.
|
||||
if stage == StageInputInstance || stage == StageInputToken {
|
||||
@ -141,14 +140,7 @@ func (r *registerInputs) assignToNext(stage registerStage, value string) registe
|
||||
return StageUnknown
|
||||
}
|
||||
|
||||
func getLocalConfigFile(envFile string) (string, bool) {
|
||||
_ = godotenv.Load(envFile)
|
||||
cfg, _ := config.FromEnviron()
|
||||
return cfg.Runner.File, file.IsFile(cfg.Runner.File)
|
||||
}
|
||||
|
||||
func registerInteractive(envFile string) error {
|
||||
|
||||
var (
|
||||
reader = bufio.NewReader(os.Stdin)
|
||||
stage = StageInputInstance
|
||||
@ -236,7 +228,6 @@ func registerNoInteractive(envFile string, regArgs *registerArgs) error {
|
||||
}
|
||||
|
||||
func doRegister(cfg *config.Config, inputs *registerInputs) error {
|
||||
|
||||
ctx := context.Background()
|
||||
|
||||
// initial http client
|
||||
|
Reference in New Issue
Block a user