hanqingwu commented on code in PR #10696:
URL: https://github.com/apache/apisix/pull/10696#discussion_r1436408141


##########
apisix/cli/ops.lua:
##########
@@ -916,14 +916,37 @@ local function stop(env)
 end
 
 
+local function sleep(n)
+  execute("sleep " .. tonumber(n))
+end
+

Review Comment:
   ok



##########
apisix/cli/ops.lua:
##########
@@ -916,14 +916,37 @@ local function stop(env)
 end
 
 
+local function sleep(n)
+  execute("sleep " .. tonumber(n))
+end
+
+local function wait_stop_finish(env, n) 
+
+    for i = 1, n do
+         -- check running
+        local pid_path = env.apisix_home .. "/logs/nginx.pid"
+        local pid = util.read_file(pid_path)
+        pid = tonumber(pid)
+        if not pid or pid == 0 then
+            print("old apisix process has stopped")
+            return
+        else
+            sleep(1)
+        end
+    end
+ 
+end
+
 local function restart(env)
   -- test configuration
   test(env)
   stop(env)
+  wait_stop_finish(env,3)
   start(env)
 end
 
 
+

Review Comment:
   ok



##########
apisix/cli/ops.lua:
##########
@@ -916,14 +916,37 @@ local function stop(env)
 end
 
 
+local function sleep(n)
+  execute("sleep " .. tonumber(n))
+end
+
+local function wait_stop_finish(env, n) 
+
+    for i = 1, n do
+         -- check running
+        local pid_path = env.apisix_home .. "/logs/nginx.pid"
+        local pid = util.read_file(pid_path)
+        pid = tonumber(pid)
+        if not pid or pid == 0 then
+            print("old apisix process has stopped")
+            return
+        else
+            sleep(1)
+        end
+    end
+ 
+end

Review Comment:
   ok



##########
apisix/cli/ops.lua:
##########
@@ -806,6 +806,7 @@ local function start(env, ...)
         local ok, err, err_no = signal.kill(pid, signone)
         if ok then
             print("APISIX is running...")

Review Comment:
   but in  t/cli/test_validate_config.sh   will check this log
   
![image](https://github.com/apache/apisix/assets/7521141/35cee7a7-3185-47d8-a4b4-6b843894c9c8)
   
   



##########
apisix/cli/ops.lua:
##########
@@ -916,10 +916,15 @@ local function stop(env)
 end
 
 
+local function sleep(n)
+  execute("sleep " .. tonumber(n))
+end
+
 local function restart(env)
   -- test configuration
   test(env)
   stop(env)
+  sleep(1)

Review Comment:
   ok, it 's a good idea



##########
apisix/cli/ops.lua:
##########
@@ -916,10 +916,15 @@ local function stop(env)
 end
 
 
+local function sleep(n)
+  execute("sleep " .. tonumber(n))
+end
+
 local function restart(env)
   -- test configuration
   test(env)
   stop(env)
+  sleep(1)

Review Comment:
   ```
   /usr/local/openresty//luajit/bin/luajit ./apisix/cli/apisix.lua start
   the old process is still running, the new one won'\''t be started!
   [ info ] run -> [ Done ]'
   + grep 'APISIX is running'
   + echo 'failed: should find APISIX running'
   + exit 1
   + clean_up
   + '[' 1 -gt 0 ']'
   + check_failure
   + cat logs/error.log
   ```
   so 'APISIX is running' is needed .



##########
apisix/cli/ops.lua:
##########
@@ -916,14 +916,37 @@ local function stop(env)
 end
 
 
+local function sleep(n)
+  execute("sleep " .. tonumber(n))
+end
+
+local function wait_stop_finish(env, n) 
+
+    for i = 1, n do
+         -- check running
+        local pid_path = env.apisix_home .. "/logs/nginx.pid"
+        local pid = util.read_file(pid_path)
+        pid = tonumber(pid)
+        if not pid or pid == 0 then
+            print("old apisix process has stopped")
+            return
+        else
+            sleep(1)
+        end
+    end
+ 
+end
+
 local function restart(env)
   -- test configuration
   test(env)
   stop(env)
+  wait_stop_finish(env,3)

Review Comment:
   ok



##########
apisix/cli/ops.lua:
##########
@@ -916,14 +916,37 @@ local function stop(env)
 end
 
 
+local function sleep(n)
+  execute("sleep " .. tonumber(n))
+end
+
+local function wait_stop_finish(env, n) 
+
+    for i = 1, n do

Review Comment:
   ok



##########
apisix/cli/ops.lua:
##########
@@ -916,14 +916,37 @@ local function stop(env)
 end
 
 
+local function sleep(n)
+  execute("sleep " .. tonumber(n))
+end
+
+local function wait_stop_finish(env, n) 
+
+    for i = 1, n do
+         -- check running
+        local pid_path = env.apisix_home .. "/logs/nginx.pid"
+        local pid = util.read_file(pid_path)
+        pid = tonumber(pid)
+        if not pid or pid == 0 then

Review Comment:
   ok ,remove pid==0



##########
apisix/cli/ops.lua:
##########
@@ -806,6 +806,7 @@ local function start(env, ...)
         local ok, err, err_no = signal.kill(pid, signone)
         if ok then
             print("APISIX is running...")

Review Comment:
   and in t/cli/test_cmd.sh
   
![image](https://github.com/apache/apisix/assets/7521141/5b8b9414-b2bb-4478-aa70-dd701742ac2e)
   



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