added log lines and changed config path for deployment

This commit is contained in:
2026-04-18 19:10:18 -06:00
parent 6457991977
commit 5c7bb72307
4 changed files with 10 additions and 2 deletions
+2
View File
@@ -17,6 +17,7 @@ type AuthConfig struct {
Token string `toml:"token"` Token string `toml:"token"`
} }
/* Function kept for reference for future logic
func NewConfig() *Config { func NewConfig() *Config {
return &Config{ return &Config{
CacheRoot: "/home/ewpt3ch/dev/pacman-cache-server/tmprepo", CacheRoot: "/home/ewpt3ch/dev/pacman-cache-server/tmprepo",
@@ -25,6 +26,7 @@ func NewConfig() *Config {
Auth: AuthConfig{Token: "FakeToken"}, Auth: AuthConfig{Token: "FakeToken"},
} }
} }
*/
func ReadConfig(path string) (*Config, error) { func ReadConfig(path string) (*Config, error) {
+2
View File
@@ -1,6 +1,7 @@
package main package main
import ( import (
"log"
"net/http" "net/http"
) )
@@ -10,6 +11,7 @@ func (s *Server) handlerRefresh(w http.ResponseWriter, req *http.Request) {
return return
} }
if err := s.c.Refresh(); err != nil { if err := s.c.Refresh(); err != nil {
log.Printf("refresh failed: %v", err)
http.Error(w, "refresh failed", http.StatusInternalServerError) http.Error(w, "refresh failed", http.StatusInternalServerError)
return return
} }
+5 -1
View File
@@ -2,6 +2,7 @@ package main
import ( import (
"errors" "errors"
"log"
"net/http" "net/http"
"os" "os"
"path/filepath" "path/filepath"
@@ -23,12 +24,15 @@ func (s *Server) handlePackage(w http.ResponseWriter, req *http.Request) {
if err != nil { if err != nil {
var upstreamErr *cache.UpstreamError var upstreamErr *cache.UpstreamError
if errors.As(err, &upstreamErr) { if errors.As(err, &upstreamErr) {
log.Printf("upstream error: %v", err)
http.Error(w, "Not found upstream", upstreamErr.StatusCode) http.Error(w, "Not found upstream", upstreamErr.StatusCode)
return return
} }
log.Printf("fetch error: %v", err)
http.Error(w, "Failed to fetch from upstream", http.StatusBadGateway) http.Error(w, "Failed to fetch from upstream", http.StatusBadGateway)
return
} }
} }
http.ServeFile(w, req, cachePath) http.ServeFile(w, req, cachePath)
+1 -1
View File
@@ -13,7 +13,7 @@ type Server struct {
} }
func main() { func main() {
cfg, err := ReadConfig("/home/ewpt3ch/dev/pacman-cache-server/tmprepo/app.config.toml") cfg, err := ReadConfig("/etc/pkgstash/pkgstash.toml")
if err != nil { if err != nil {
log.Fatal(err) log.Fatal(err)
} }