mirror of
https://github.com/hanzo-git/runner.git
synced 2026-10-30 19:33:27 +00:00
Native runner: module github.com/hanzo-git/runner, wire proto github.com/hanzo-git/actions-proto-go, command git-runner, GIT_* env, git expr context, git_* task-context keys, ghcr.io/hanzoai/runner-ubuntu job images. Derived work — upstream attribution + MIT terms in NOTICE/LICENSE. Co-authored-by: Hanzo Dev <[email protected]>
75 lines
1.5 KiB
Go
75 lines
1.5 KiB
Go
// Copyright 2023 The Git Authors. All rights reserved.
|
|
// SPDX-License-Identifier: MIT
|
|
|
|
package cmd
|
|
|
|
import (
|
|
"errors"
|
|
"fmt"
|
|
"os"
|
|
"os/signal"
|
|
|
|
"github.com/hanzo-git/runner/act/artifactcache"
|
|
"github.com/hanzo-git/runner/internal/pkg/config"
|
|
|
|
log "github.com/sirupsen/logrus"
|
|
"github.com/spf13/cobra"
|
|
)
|
|
|
|
type cacheServerArgs struct {
|
|
Dir string
|
|
Host string
|
|
Port uint16
|
|
}
|
|
|
|
func runCacheServer(configFile *string, cacheArgs *cacheServerArgs) func(cmd *cobra.Command, args []string) error {
|
|
return func(cmd *cobra.Command, args []string) error {
|
|
cfg, err := config.LoadDefault(*configFile)
|
|
if err != nil {
|
|
return fmt.Errorf("invalid configuration: %w", err)
|
|
}
|
|
|
|
initLogging(cfg)
|
|
|
|
var (
|
|
dir = cfg.Cache.Dir
|
|
host = cfg.Cache.Host
|
|
port = cfg.Cache.Port
|
|
)
|
|
|
|
// cacheArgs has higher priority
|
|
if cacheArgs.Dir != "" {
|
|
dir = cacheArgs.Dir
|
|
}
|
|
if cacheArgs.Host != "" {
|
|
host = cacheArgs.Host
|
|
}
|
|
if cacheArgs.Port != 0 {
|
|
port = cacheArgs.Port
|
|
}
|
|
|
|
secret := cfg.Cache.ExternalSecret
|
|
if secret == "" {
|
|
return errors.New("cache.external_secret must be set for cache-server; configure the same value on each runner that points at this server via cache.external_server")
|
|
}
|
|
cacheHandler, err := artifactcache.StartHandler(
|
|
dir,
|
|
host,
|
|
port,
|
|
secret,
|
|
log.StandardLogger().WithField("module", "cache_request"),
|
|
)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
|
|
log.Infof("cache server is listening on %v", cacheHandler.ExternalURL())
|
|
|
|
c := make(chan os.Signal, 1)
|
|
signal.Notify(c, os.Interrupt)
|
|
<-c
|
|
|
|
return nil
|
|
}
|
|
}
|