Add cachePath variable and CLI option
This commit is contained in:
@@ -20,6 +20,7 @@ func main() {
|
||||
set := flag.NewFlagSet(version.NAME, flag.ExitOnError)
|
||||
listenAddr := set.String("listen-addr", "0.0.0.0:4747", "listen address (optional)")
|
||||
musicPath := set.String("music-path", "", "path to music")
|
||||
cachePath := set.String("cache-path", "", "path to cache")
|
||||
dbPath := set.String("db-path", "gonic.db", "path to database (optional)")
|
||||
scanInterval := set.Int("scan-interval", 0, "interval (in minutes) to automatically scan music (optional)")
|
||||
proxyPrefix := set.String("proxy-prefix", "", "url path prefix to use if behind proxy. eg '/gonic' (optional)")
|
||||
@@ -39,6 +40,9 @@ func main() {
|
||||
if _, err := os.Stat(*musicPath); os.IsNotExist(err) {
|
||||
log.Fatal("please provide a valid music directory")
|
||||
}
|
||||
if _, err := os.Stat(*cachePath); os.IsNotExist(err) {
|
||||
log.Fatal("please provide a valid cache directory")
|
||||
}
|
||||
db, err := db.New(*dbPath)
|
||||
if err != nil {
|
||||
log.Fatalf("error opening database: %v\n", err)
|
||||
@@ -49,6 +53,7 @@ func main() {
|
||||
serverOptions := server.Options{
|
||||
DB: db,
|
||||
MusicPath: *musicPath,
|
||||
CachePath: *cachePath,
|
||||
ListenAddr: *listenAddr,
|
||||
ScanInterval: time.Duration(*scanInterval) * time.Minute,
|
||||
ProxyPrefix: *proxyPrefix,
|
||||
|
||||
Reference in New Issue
Block a user