jiangfucheng commented on code in PR #9521:
URL: https://github.com/apache/apisix/pull/9521#discussion_r1201811919


##########
apisix/cli/ops.lua:
##########
@@ -807,17 +807,19 @@ local function start(env, ...)
         local local_conf_path = profile:yaml_path("config")
         local local_conf_path_bak = local_conf_path .. ".bak"
 
-        local ok, err = os_rename(local_conf_path, local_conf_path_bak)
-        if not ok then
-            util.die("failed to backup config, error: ", err)
-        end
-        local ok, err1 = lfs.link(customized_yaml, local_conf_path)
-        if not ok then
-            ok, err = os_rename(local_conf_path_bak,  local_conf_path)
+        if not pl_path.exists(local_conf_path_bak) then
+            local ok, err = os_rename(local_conf_path, local_conf_path_bak)
             if not ok then
-                util.die("failed to recover original config file, error: ", 
err)
+                util.die("failed to backup config, error: ", err)
+            end
+            local ok, err1 = lfs.link(customized_yaml, local_conf_path)
+            if not ok then
+                ok, err = os_rename(local_conf_path_bak,  local_conf_path)
+                if not ok then
+                    util.die("failed to recover original config file, error: 
", err)
+                end
+                util.die("failed to link customized config, error: ", err1)
             end
-            util.die("failed to link customized config, error: ", err1)
         end

Review Comment:
   Once start APISIX use customized config, the original `config.yaml ` will be 
`rename` to `config.yaml.bak`  and set a hard link from customized config to 
`config.yaml`, if occur some errors cause start APISIX fail then it will not 
restore these config files, so we don't need do above opeartion again, just use 
`config.yaml` as apisix config directly is enough.
   Unless the user create `local_conf_path_bak` manually before start apisix. 
   If we can detected if have errors when start APISIX, it maybe the best 
solution, but, I have no idea about this. 



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

To unsubscribe, e-mail: [email protected]

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

Reply via email to