file added
This commit is contained in:
34
cmd/zurg/main.go
Normal file
34
cmd/zurg/main.go
Normal file
@@ -0,0 +1,34 @@
|
|||||||
|
package main
|
||||||
|
|
||||||
|
import (
|
||||||
|
"fmt"
|
||||||
|
"log"
|
||||||
|
"net/http"
|
||||||
|
"time"
|
||||||
|
|
||||||
|
"github.com/debridmediamanager.com/zurg/internal/config"
|
||||||
|
"github.com/debridmediamanager.com/zurg/internal/net"
|
||||||
|
"github.com/debridmediamanager.com/zurg/internal/torrent"
|
||||||
|
"github.com/hashicorp/golang-lru/v2/expirable"
|
||||||
|
)
|
||||||
|
|
||||||
|
func main() {
|
||||||
|
config, configErr := config.LoadZurgConfig("./config.yml")
|
||||||
|
if configErr != nil {
|
||||||
|
log.Panicf("Config failed to load: %v", configErr)
|
||||||
|
}
|
||||||
|
|
||||||
|
cache := expirable.NewLRU[string, string](1e4, nil, time.Hour)
|
||||||
|
|
||||||
|
t := torrent.NewTorrentManager(config, cache)
|
||||||
|
|
||||||
|
mux := http.NewServeMux()
|
||||||
|
net.Router(mux, config, t, cache)
|
||||||
|
|
||||||
|
addr := fmt.Sprintf(":%s", config.GetPort())
|
||||||
|
log.Printf("Starting server on %s\n", addr)
|
||||||
|
err := http.ListenAndServe(addr, mux)
|
||||||
|
if err != nil {
|
||||||
|
log.Panicf("Failed to start server: %v", err)
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user