~emersion/soju-dev

Check for configuration in /etc/soju/config v1 REJECTED

Philip Kaludercic: 1
 Check for configuration in /etc/soju/config

 2 files changed, 22 insertions(+), 10 deletions(-)
Export patchset (mbox)
How do I use this?

Copy & paste the following snippet into your terminal to import this patchset into git:

curl -s https://lists.sr.ht/~emersion/soju-dev/patches/22957/mbox | git am -3
Learn more about email & git
View this thread in the archives

[PATCH] Check for configuration in /etc/soju/config Export this patch

If no configuration path was specified, check if /etc/soju/config
exists before using the default configuration.
---
 cmd/soju/main.go    | 16 +++++++++++-----
 cmd/sojuctl/main.go | 16 +++++++++++-----
 2 files changed, 22 insertions(+), 10 deletions(-)

diff --git a/cmd/soju/main.go b/cmd/soju/main.go
index f7f8a42..5f94e2e 100644
--- a/cmd/soju/main.go
+++ b/cmd/soju/main.go
@@ -46,14 +46,20 @@ func main() {
	flag.Parse()

	var cfg *config.Server
	var err error
	if configPath != "" {
		var err error
		cfg, err = config.Load(configPath)
		if err != nil {
			log.Fatalf("failed to load config file: %v", err)
		}
	} else {
		cfg = config.Defaults()
		configPath = `/etc/soju/config`
		_, err = os.Stat(configPath)
		if os.IsNotExist(err) {
			cfg = config.Defaults()
		} else if err == nil {
			cfg, err = config.Load(configPath)
		}
	}
	if err != nil {
		log.Fatalf("failed to load config file: %v", err)
	}

	cfg.Listen = append(cfg.Listen, listen...)
diff --git a/cmd/sojuctl/main.go b/cmd/sojuctl/main.go
index 730832c..e290914 100644
--- a/cmd/sojuctl/main.go
+++ b/cmd/sojuctl/main.go
@@ -33,14 +33,20 @@ func main() {
	flag.Parse()

	var cfg *config.Server
	var err error
	if configPath != "" {
		var err error
		cfg, err = config.Load(configPath)
		if err != nil {
			log.Fatalf("failed to load config file: %v", err)
		}
	} else {
		cfg = config.Defaults()
		configPath = `/etc/soju/config`
		_, err = os.Stat(configPath)
		if os.IsNotExist(err) {
			cfg = config.Defaults()
		} else if err == nil {
			cfg, err = config.Load(configPath)
		}
	}
	if err != nil {
		log.Fatalf("failed to load config file: %v", err)
	}

	db, err := soju.OpenSQLDB(cfg.SQLDriver, cfg.SQLSource)
-- 
2.30.2
Sorry, I've decided against this approach, and instead let the service
specify `-config /etc/soju/config`.