bisakhmondal commented on a change in pull request #1667:
URL: https://github.com/apache/apisix-dashboard/pull/1667#discussion_r618091085



##########
File path: api/cmd/managerapi.go
##########
@@ -59,6 +60,14 @@ func printVersion() {
 
 // NewManagerAPICommand creates the manager-api command.
 func NewManagerAPICommand() *cobra.Command {
+       cobra.OnInitialize(func() {
+               var err error
+               service, err = createService()
+               if err != nil {
+                       fmt.Fprintf(os.Stderr, "error occurred while 
initializing service: %s", err)

Review comment:
       I  avoided quitting because executing plain `./manager-api` doesn't 
require service struct 
[ref](https://github.com/apache/apisix-dashboard/pull/1667/files#diff-2f6f18308ee739c91dc10135e339dc5ba94e1a447391574c020890e0039d15b1R80).
 If somehow `createService` returns a nil service and service-specific commands 
are used go runtime manager will throw an error of referencing a nil struct 
before any line of actual logic of manager-api being executed (slightly 
ungrateful though). Let me know what you think.




-- 
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