mirror of
https://blitiri.com.ar/repos/chasquid
synced 2025-12-21 15:17:01 +00:00
chasquid: Do a Chdir into the configuration directory
In some cases, it's be useful to have references to directories relative to the configuration itself. So this patch makes chasquid do a Chdir into it, so we can assume it in the rest of the code and config.
This commit is contained in:
12
chasquid.go
12
chasquid.go
@@ -60,6 +60,13 @@ func main() {
|
||||
glog.Fatalf("Error reading config")
|
||||
}
|
||||
|
||||
// Change to the config dir.
|
||||
// This allow us to use relative paths for configuration directories.
|
||||
// It also can be useful in unusual environments and for testing purposes,
|
||||
// where paths inside the configuration itself could be relative, and this
|
||||
// fixes the point of reference.
|
||||
os.Chdir(*configDir)
|
||||
|
||||
if conf.MonitoringAddress != "" {
|
||||
glog.Infof("Monitoring HTTP server listening on %s",
|
||||
conf.MonitoringAddress)
|
||||
@@ -74,7 +81,8 @@ func main() {
|
||||
s.MaxDataSize = conf.MaxDataSizeMb * 1024 * 1024
|
||||
|
||||
// Load domains.
|
||||
domainDirs, err := ioutil.ReadDir(*configDir + "/domains/")
|
||||
// They live inside the config directory, so the relative path works.
|
||||
domainDirs, err := ioutil.ReadDir("domains/")
|
||||
if err != nil {
|
||||
glog.Fatalf("Error in glob: %v", err)
|
||||
}
|
||||
@@ -85,7 +93,7 @@ func main() {
|
||||
glog.Infof("Domain config paths:")
|
||||
for _, info := range domainDirs {
|
||||
name := info.Name()
|
||||
dir := filepath.Join(*configDir, "domains", name)
|
||||
dir := filepath.Join("domains", name)
|
||||
loadDomain(s, name, dir)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user