Removed code for liquidsoap.
This commit is contained in:
parent
4512e6aa53
commit
38f04aa9f8
@ -5,7 +5,6 @@ import (
|
||||
"dwelling-radio/internal/http"
|
||||
"dwelling-radio/internal/radio"
|
||||
"dwelling-radio/web"
|
||||
"errors"
|
||||
"flag"
|
||||
"fmt"
|
||||
"io/fs"
|
||||
@ -19,8 +18,7 @@ import (
|
||||
)
|
||||
|
||||
var (
|
||||
configPath *string = flag.String("conf", "config.yaml", "path to configuration file")
|
||||
noLiquidsoap *bool = flag.Bool("no-liquidsoap", false, "don't run liquidsoap")
|
||||
configPath *string = flag.String("conf", "config.yaml", "path to configuration file")
|
||||
|
||||
showVersion *bool = flag.Bool("v", false, "show version")
|
||||
)
|
||||
@ -53,19 +51,6 @@ func main() {
|
||||
}
|
||||
defer playlistWatcher.Close()
|
||||
|
||||
if !*noLiquidsoap {
|
||||
liquid, err := radio.NewLiquidsoap(config.Liquidsoap.ExecPath, config.Liquidsoap.ScriptPath)
|
||||
if err != nil {
|
||||
log.Fatalln("liquidsoap:", err)
|
||||
}
|
||||
|
||||
defer func() {
|
||||
if err := liquid.Stop(); err != nil && !errors.Is(err, radio.ErrLiquidsoapNotRunning) {
|
||||
log.Println(err)
|
||||
}
|
||||
}()
|
||||
}
|
||||
|
||||
hand := http.NewHandlers(config)
|
||||
r := httpr.New()
|
||||
|
||||
|
@ -8,8 +8,5 @@ icecast:
|
||||
playlist_path: "playlist.log"
|
||||
filelist_path: "/srv/radio/filelist.html"
|
||||
most_listened_song_file_path: "/mnt/data/appdata/mostlistenedsong"
|
||||
liquidsoap:
|
||||
executable_path: "/opt/opam/4.14.0/bin/liquidsoap"
|
||||
script_path: "/etc/dwelling/radio.liq"
|
||||
# How much songs to list on a page
|
||||
list_last_n_songs: 10
|
@ -8,8 +8,5 @@ icecast:
|
||||
playlist_path: "/var/log/icecast/playlist.log"
|
||||
filelist_path: "/srv/radio/filelist.html"
|
||||
most_listened_song_file_path: "/mnt/data/appdata/mostlistenedsong"
|
||||
liquidsoap:
|
||||
executable_path: "/opt/opam/4.14.0/bin/liquidsoap"
|
||||
script_path: "/etc/dwelling/radio.liq"
|
||||
# How much songs to list on a page
|
||||
list_last_n_songs: 10
|
@ -7,7 +7,7 @@ After=network-online.target icecast.service
|
||||
Type=simple
|
||||
Restart=on-failure
|
||||
DynamicUser=yes
|
||||
ExecStart=/usr/bin/dwelling-radio -no-liquidsoap -conf /etc/dwelling/radio.yaml
|
||||
ExecStart=/usr/bin/dwelling-radio -conf /etc/dwelling/radio.yaml
|
||||
|
||||
ReadOnlyPaths=/
|
||||
|
||||
|
@ -16,11 +16,7 @@ type Configuration struct {
|
||||
} `yaml:"icecast"`
|
||||
FilelistPath string `yaml:"filelist_path"`
|
||||
MostListenedSongPath string `yaml:"most_listened_song_file_path"`
|
||||
Liquidsoap struct {
|
||||
ExecPath string `yaml:"executable_path"`
|
||||
ScriptPath string `yaml:"script_path"`
|
||||
} `yaml:"liquidsoap"`
|
||||
ListLastNSongs int `yaml:"list_last_n_songs"`
|
||||
ListLastNSongs int `yaml:"list_last_n_songs"`
|
||||
}
|
||||
|
||||
// Load reads a YAML file that stores configuration of a service.
|
||||
|
@ -1,54 +0,0 @@
|
||||
package radio
|
||||
|
||||
import (
|
||||
"os/exec"
|
||||
"syscall"
|
||||
|
||||
"github.com/pkg/errors"
|
||||
)
|
||||
|
||||
var ErrLiquidsoapNotRunning = errors.New("liquidsoap is not running")
|
||||
|
||||
type Liquidsoap struct {
|
||||
command *exec.Cmd
|
||||
}
|
||||
|
||||
func NewLiquidsoap(liquidsoapPath, scriptPath string) (*Liquidsoap, error) {
|
||||
if _, err := exec.LookPath(liquidsoapPath); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
out, err := exec.Command(liquidsoapPath, "--verbose", "-c", scriptPath).CombinedOutput()
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "script cannot be validated")
|
||||
}
|
||||
|
||||
if len(out) > 0 {
|
||||
return nil, errors.Errorf("script validation failed: %s", string(out))
|
||||
}
|
||||
|
||||
cmd := exec.Command(liquidsoapPath, scriptPath)
|
||||
|
||||
if err := cmd.Start(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return &Liquidsoap{
|
||||
command: cmd}, nil
|
||||
}
|
||||
|
||||
func (l *Liquidsoap) Stop() error {
|
||||
if l.command.Process == nil && l.command.ProcessState != nil {
|
||||
return ErrLiquidsoapNotRunning
|
||||
}
|
||||
|
||||
if err := l.command.Process.Signal(syscall.SIGINT); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if err := l.command.Wait(); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
Loading…
Reference in New Issue
Block a user