From 5080765a7026a740c833a8ce3f1d31800407d138 Mon Sep 17 00:00:00 2001 From: 2weiEmu Date: Tue, 10 Mar 2026 00:36:30 +0100 Subject: [PATCH] updated: first parts of the code, flags etc. --- .gitignore | 1 + Makefile | 4 ++++ README.md | 2 ++ go.mod | 5 +++++ go.sum | 4 ++++ main.go | 40 ++++++++++++++++++++++++++++++++++++++++ 6 files changed, 56 insertions(+) create mode 100644 .gitignore create mode 100644 Makefile create mode 100644 go.mod create mode 100644 go.sum create mode 100644 main.go diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..26618f0 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +log/sm.log diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..e2c442d --- /dev/null +++ b/Makefile @@ -0,0 +1,4 @@ + + +default: . + go run . diff --git a/README.md b/README.md index 36c976b..a03aaec 100644 --- a/README.md +++ b/README.md @@ -21,6 +21,8 @@ Seeing as this is just supposed to be a simple local site used in the house, und # Flags +- port + The port you want to host this on, definitely required. - binb_location=[location of binb sis50] We need this so we know where to run the scripts - songs_location=[the location of the public songs directory] diff --git a/go.mod b/go.mod new file mode 100644 index 0000000..904ba56 --- /dev/null +++ b/go.mod @@ -0,0 +1,5 @@ +module songmanager + +go 1.25.0 + +require golang.org/x/net v0.51.0 diff --git a/go.sum b/go.sum new file mode 100644 index 0000000..ddf8620 --- /dev/null +++ b/go.sum @@ -0,0 +1,4 @@ +golang.org/x/net v0.51.0 h1:94R/GTO7mt3/4wIKpcR5gkGmRLOuE/2hNGeWq/GBIFo= +golang.org/x/net v0.51.0/go.mod h1:aamm+2QF5ogm02fjy5Bb7CQ0WMt1/WVM7FtyaTLlA9Y= +golang.org/x/sys v0.41.0 h1:Ivj+2Cp/ylzLiEU89QhWblYnOE9zerudt9Ftecq2C6k= +golang.org/x/sys v0.41.0/go.mod h1:OgkHotnGiDImocRcuBABYBEXf8A9a87e/uXjp9XT3ks= diff --git a/main.go b/main.go new file mode 100644 index 0000000..0a0da9e --- /dev/null +++ b/main.go @@ -0,0 +1,40 @@ +package main + +import ( + "flag" + "fmt" + "log" + "os" +) + +func main() { + // Getting the parameters + paramPort := flag.Int("port", 8000, "Specify the port you want to host this server on. By default: 8000") + paramBinbLocation := flag.String("binb_location", "", "Specify the folder containing the app.js for the binb version you are running") + paramSongsLocation := flag.String("song_location", "", "Specify the /public/songs folder where the m4a preview files should be saved.") + paramRedisLocation := flag.String("redis_location", "", "Specify the location of the redis instance to open, probably a localhost place.") + paramContainerName := flag.String("container_name", "", "Specify the name of the container image that would have to be started / restarted") + + flag.Parse() + + // Setting up logging + logFile, err := os.OpenFile("./log/sm.log", os.O_APPEND | os.O_RDWR, 0664) + if err != nil { + fmt.Println("While setting up the server, it could not open the main log file at log/sm.log.", err) + panic("Failed to open log file."); + } + + defer logFile.Close() + + mainLogger := log.New(logFile, "", log.LstdFlags | log.Lshortfile | log.Ldate | log.Ltime) + mainLogger.Println("=== Logging has begun. === ") + mainLogger.Println("Given port:", paramPort) + mainLogger.Println("Given binb_location:", paramBinbLocation) + mainLogger.Println("Given songs_location:", paramSongsLocation) + mainLogger.Println("Given redis_location:", paramRedisLocation) + mainLogger.Println("Given container_name:", paramContainerName) + + + // Setting up the routing + +} -- 2.54.0