feat: add upstream and verbose flags to command line interface
All checks were successful
Release Tag / release (push) Successful in 13s

feat: add upstream support allowing to chain cache servers if needed
fix: tweaked garbage collection to be better
This commit is contained in:
2025-01-23 11:14:39 -06:00
parent 931c43d7a8
commit e24af47697
11 changed files with 310 additions and 103 deletions

View File

@@ -4,6 +4,7 @@ import (
"os"
"s1d3sw1ped/SteamCache2/steamcache"
"github.com/rs/zerolog"
"github.com/spf13/cobra"
)
@@ -13,6 +14,10 @@ var (
disk string
diskmultiplier int
diskpath string
upstream string
pprof bool
verbose bool
)
var rootCmd = &cobra.Command{
@@ -24,6 +29,10 @@ var rootCmd = &cobra.Command{
By caching game files, SteamCache2 ensures that subsequent downloads of the same files are served from the local cache,
significantly improving download times and reducing the load on the internet connection.`,
Run: func(cmd *cobra.Command, args []string) {
if verbose {
zerolog.SetGlobalLevel(zerolog.DebugLevel)
}
sc := steamcache.New(
":80",
memory,
@@ -31,6 +40,8 @@ var rootCmd = &cobra.Command{
disk,
diskmultiplier,
diskpath,
upstream,
pprof,
)
sc.Run()
},
@@ -51,4 +62,10 @@ func init() {
rootCmd.Flags().StringVarP(&disk, "disk", "d", "0", "The size of the disk cache")
rootCmd.Flags().IntVarP(&diskmultiplier, "disk-gc", "D", 100, "The gc value for the disk cache")
rootCmd.Flags().StringVarP(&diskpath, "disk-path", "p", "", "The path to the disk cache")
rootCmd.Flags().StringVarP(&upstream, "upstream", "u", "", "The upstream server to proxy requests overrides the host header from the client but forwards the original host header to the upstream server")
rootCmd.Flags().BoolVarP(&pprof, "pprof", "P", false, "Enable pprof")
rootCmd.Flags().MarkHidden("pprof")
rootCmd.Flags().BoolVarP(&verbose, "verbose", "v", false, "Enable verbose logging")
}