From 698d7787e672dc22dc31a310a383c2404915c676 Mon Sep 17 00:00:00 2001 From: "Alexander \"Arav\" Andreev" Date: Mon, 2 Oct 2023 03:13:39 +0400 Subject: [PATCH] A separate executable dwelling-radiodj was removed. --- Makefile | 20 +++---- cmd/dwelling-radiodj/main.go | 102 ----------------------------------- 2 files changed, 8 insertions(+), 114 deletions(-) delete mode 100644 cmd/dwelling-radiodj/main.go diff --git a/Makefile b/Makefile index f90ea72..7ac762a 100755 --- a/Makefile +++ b/Makefile @@ -25,21 +25,20 @@ endif run: bin/dwelling-radio -listen 127.0.0.1:18322 -mls-file ./mls-test \ - -ic-url http://radio.arav.home.arpa/status-json.xsl -ic-playlist ./p.log + -playlist /mnt/data/appdata/radio/playlists/all-rand run-dj: bin/dwelling-radiodj -listen 127.0.0.1:18323 -list-length 10 \ - -playlist /mnt/data/appdata/radio/playlists/all-rand \ + -mls-file ./mls-test install: install -Dm 0755 bin/${TARGET} ${DESTDIR}${PREFIX}/bin/${TARGET} - install -Dm 0755 bin/${TARGET}dj ${DESTDIR}${PREFIX}/bin/${TARGET}dj install -Dm 0755 tools/radioctl ${DESTDIR}${PREFIX}/bin/${TARGET}ctl - install -Dm 0755 tools/radiodj-fetch ${DESTDIR}${PREFIX}/bin/${TARGET}dj-fetch - install -Dm 0755 tools/radiodj-listener-connect ${DESTDIR}${PREFIX}/bin/${TARGET}dj-listener-connect - install -Dm 0755 tools/radiodj-listener-disconnect ${DESTDIR}${PREFIX}/bin/${TARGET}dj-listener-disconnect + install -Dm 0755 tools/radio-fetch ${DESTDIR}${PREFIX}/bin/${TARGET}-fetch + install -Dm 0755 tools/radio-listener-connect ${DESTDIR}${PREFIX}/bin/${TARGET}-listener-connect + install -Dm 0755 tools/radio-listener-disconnect ${DESTDIR}${PREFIX}/bin/${TARGET}dj-listener-disconnect install -Dm 0644 configs/radio.liq ${DESTDIR}/etc/dwelling/radio.liq install -Dm 0644 configs/radio.vars.liq ${DESTDIR}/etc/dwelling/radio.vars.liq @@ -47,25 +46,22 @@ install: install -Dm 0644 configs/logrotate ${DESTDIR}/etc/logrotate.d/${TARGET} install -Dm 0644 init/radio.service ${DESTDIR}/${SYSDDIR}/${TARGET}.service - install -Dm 0644 init/radiodj.service ${DESTDIR}/${SYSDDIR}/${TARGET}dj.service install -Dm 0644 init/liquidsoap.service ${DESTDIR}/${SYSDDIR}/${TARGET}-liquidsoap.service install -Dm 0644 init/ezstream.service ${DESTDIR}/${SYSDDIR}/${TARGET}-ezstream.service uninstall: rm ${DESTDIR}${PREFIX}/bin/${TARGET} - rm ${DESTDIR}${PREFIX}/bin/${TARGET}dj rm ${DESTDIR}${PREFIX}/bin/${TARGET}ctl - rm ${DESTDIR}${PREFIX}/bin/${TARGET}dj-fetch - rm ${DESTDIR}${PREFIX}/bin/${TARGET}dj-listener-connect - rm ${DESTDIR}${PREFIX}/bin/${TARGET}dj-listener-disconnect + rm ${DESTDIR}${PREFIX}/bin/${TARGET}-fetch + rm ${DESTDIR}${PREFIX}/bin/${TARGET}-listener-connect + rm ${DESTDIR}${PREFIX}/bin/${TARGET}-listener-disconnect rm ${DESTDIR}/etc/dwelling/radio.liq rm ${DESTDIR}/etc/dwelling/ezstream.xml rm ${DESTDIR}/etc/logrotate.d/${TARGET} rm ${DESTDIR}${SYSDDIR}/${TARGET}.service - rm ${DESTDIR}${SYSDDIR}/${TARGET}dj.service rm ${DESTDIR}${SYSDDIR}/${TARGET}-liquidsoap.service rm ${DESTDIR}${SYSDDIR}/${TARGET}-ezstream.service diff --git a/cmd/dwelling-radiodj/main.go b/cmd/dwelling-radiodj/main.go deleted file mode 100644 index 01d1803..0000000 --- a/cmd/dwelling-radiodj/main.go +++ /dev/null @@ -1,102 +0,0 @@ -package main - -import ( - ihttp "dwelling-radio/internal/http" - "dwelling-radio/internal/radio" - "flag" - "fmt" - "io/fs" - "log" - "net/http" - "os" - "os/signal" - "syscall" - - "git.arav.su/Arav/httpr" -) - -var ( - listenAddress = flag.String("listen", "/var/run/dwelling-radio/sock", "listen address (ip:port|unix_path)") - playlist = flag.String("playlist", "", "path to a playlist") - songListLen = flag.Int("list-length", 10, "number of songs to show in last N songs table") - mostListenedSongPath = flag.String("mls-file", "/mnt/data/appdata/radio/mostlistenedsong", "path to a file that stores info about the most listened song") - - showVersion = flag.Bool("v", false, "show version") -) - -var version string - -func main() { - flag.Parse() - log.SetFlags(log.Lshortfile) - - if *showVersion { - fmt.Println("dwelling-radio ver.", version, "\nCopyright (c) 2023 Alexander \"Arav\" Andreev ") - return - } - - r := httpr.New() - - lstnrs := radio.NewListenerCounter() - plylst, err := radio.NewPlaylist(*playlist, true) - if err != nil { - log.Fatalln(err) - } - - if data, err := os.ReadFile(*mostListenedSongPath); err == nil { - if err := radio.LoadMostListenedSong(data); err != nil { - log.Fatalln(err) - } - } - - djh := ihttp.NewDJHandlers(lstnrs, plylst, *songListLen) - - s := r.Sub("/listener") - s.Handler(http.MethodGet, "/", djh.ListenersGet) - s.Handler(http.MethodPost, "/", djh.ListenersInc) - s.Handler(http.MethodDelete, "/", djh.ListenersDec) - - r.Handler(http.MethodGet, "/playlist", djh.PlaylistNext) - - r.Handler(http.MethodGet, "/song", djh.Song) - r.Handler(http.MethodGet, "/songs", djh.Songs) - - r.Handler(http.MethodGet, "/status", djh.Status) - - r.Handler(http.MethodGet, "/mostlistenedsong", djh.MostListenedSong) - - srv := ihttp.NewHttpServer(r) - - if err := srv.Start(*listenAddress); err != nil { - log.Fatalln(err) - } - - defer func() { - fileData := radio.StoreMostListenedSong() - if fileData != nil { - err := os.WriteFile(*mostListenedSongPath, fileData, fs.ModePerm) - if err != nil { - log.Println("failed to store a most listened song:", err) - } - } - - if err := srv.Stop(); err != nil { - log.Fatalln(err) - } - }() - - doneSignal := make(chan os.Signal, 1) - signal.Notify(doneSignal, os.Interrupt, syscall.SIGINT, syscall.SIGTERM, syscall.SIGSEGV) - - reloadSignal := make(chan os.Signal, 1) - signal.Notify(reloadSignal, syscall.SIGHUP) - - go func() { - for { - <-reloadSignal - plylst.Reload() - } - }() - - <-doneSignal -}