Fix working directory, see #47299-files-serving
@@ -7,14 +7,12 @@ import (
"flag"
"os"
"path/filepath"
- "strings"
"github.com/sirupsen/logrus"
"go.avenga.cloud/couper/gateway/command"
"go.avenga.cloud/couper/gateway/config"
"go.avenga.cloud/couper/gateway/server"
- "go.avenga.cloud/couper/gateway/utils"
)
const defaultConfigFile = "example.hcl"
@@ -33,20 +31,17 @@ func main() {
exampleConf := config.LoadFile(*configFile, logger)
- if *configFile != "" && strings.HasPrefix(*configFile, "/") {
- exampleConf.WD = filepath.Dir(*configFile)
- } else {
+ err := os.Chdir(filepath.Dir(*configFile))
+ if err != nil {
+ panic(err)
+ }
+
wd, err := os.Getwd()
if err != nil {
panic(err)
}
- if *configFile == defaultConfigFile {
exampleConf.WD = wd
- } else {
- exampleConf.WD = utils.JoinPath(wd, *configFile)
- }
- }
ctx := command.ContextWithSignal(context.Background())
srv := server.New(ctx, logger, exampleConf)
