Skip to content
Snippets Groups Projects
Commit e504a1c6 authored by Travis Ralston's avatar Travis Ralston
Browse files

Offer a command-line option to change the config path

Adds #43
parent 1070a2bc
No related branches found
No related tags found
No related merge requests found
......@@ -3,7 +3,7 @@
/pkg
/logs
media-repo.yaml
media-repo*.yaml
homeserver.yaml
vendor/pkg
......
......@@ -2,6 +2,7 @@ package main
import (
"encoding/json"
"flag"
"fmt"
"io"
"net/http"
......@@ -43,6 +44,11 @@ type ApiRoute struct {
type EmptyResponse struct{}
func main() {
configPath := flag.String("config", "media-repo.yaml", "The path to the configuration")
flag.Parse()
config.Path = *configPath
rtr := mux.NewRouter()
err := logging.Setup(config.Get().General.LogDirectory)
......
......@@ -71,11 +71,12 @@ type MediaRepoConfig struct {
var instance *MediaRepoConfig
var singletonLock = &sync.Once{}
var Path = "media-repo.yaml"
func LoadConfig() (error) {
func ReloadConfig() (error) {
c := &MediaRepoConfig{}
f, err := os.Open("media-repo.yaml")
f, err := os.Open(Path)
if err != nil {
return err
}
......@@ -95,7 +96,7 @@ func LoadConfig() (error) {
func Get() (*MediaRepoConfig) {
if instance == nil {
singletonLock.Do(func() {
err := LoadConfig()
err := ReloadConfig()
if err != nil {
panic(err)
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment