imjoey edited a comment on issue #1147:
URL: 
https://github.com/apache/apisix-dashboard/issues/1147#issuecomment-753620446


   +1 for same issue.
   
   After digging deeper into this issue, I found that `conf.WorkDir` would 
always be `.`, cause the config initialization process defined in the `init()` 
function under `github.com/apisix/manager-api/internal/log` package would be 
definitely executed in prior to setting Cobra command flags. 
   
   So I could get through with this via commenting out 
https://github.com/apache/apisix-dashboard/blob/62d1c439f37c98ca459f1ce2a0c15273575d2bce/api/internal/conf/conf.go#L103-L106
 .
   
   While if proceed, I would still got the following error:
   
   ```
   ➜  apache-apisix ./manager-api -p output
   panic: couldn't open sink "logs/error.log": open logs/error.log: no such 
file or directory
   goroutine 1 [running]:
   github.com/apisix/manager-api/internal/log.fileWriter(0x1010200, 
0x1650e252fc378834, 0xc00039fdf0)
        
/Users/imjoey/Work/apache-apisix/apisix-dashboard/api/internal/log/zap.go:98 
+0x208
   github.com/apisix/manager-api/internal/log.GetLogger(0x0, 0x14)
        
/Users/imjoey/Work/apache-apisix/apisix-dashboard/api/internal/log/zap.go:38 
+0x3f
   github.com/apisix/manager-api/internal/log.InitLogger(...)
        
/Users/imjoey/Work/apache-apisix/apisix-dashboard/api/internal/log/zap.go:35
   github.com/apisix/manager-api/internal/log.init.0()
        
/Users/imjoey/Work/apache-apisix/apisix-dashboard/api/internal/log/zap.go:32 
+0x26
   ```
   
   The reason of this log error is the same as `conf.WorkDir` . So I commented 
out 
https://github.com/apache/apisix-dashboard/blob/62d1c439f37c98ca459f1ce2a0c15273575d2bce/api/internal/log/zap.go#L30-L33
 
   
   Then I added `log.InitLogger()` after the line of code: 
https://github.com/apache/apisix-dashboard/blob/62d1c439f37c98ca459f1ce2a0c15273575d2bce/api/cmd/managerapi.go#L59
 
   
   After done all the above, the bugs gone and everything worked fine. While 
honestly speaking, I'm not quite sure about the relationship between the 
**integration tests** and those two `init()` functions (See the `TODO` comments 
above the original code). You will be much appreciated if anyone can elaborate 
on it? Thanks.
   
   


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to