You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@apisix.apache.org by GitBox <gi...@apache.org> on 2022/05/10 02:00:29 UTC

[GitHub] [apisix] spacewander commented on a diff in pull request #7006: feat(ops): check process running with posix.signal insteadof lsof

spacewander commented on code in PR #7006:
URL: https://github.com/apache/apisix/pull/7006#discussion_r868736893


##########
apisix/cli/ops.lua:
##########
@@ -728,14 +729,16 @@ local function start(env, ...)
     local pid = util.read_file(pid_path)
     pid = tonumber(pid)
     if pid then
-        local lsof_cmd = "lsof -p " .. pid
-        local res, err = util.execute_cmd(lsof_cmd)
-        if not (res and res == "") then
-            if not res then
-                print(err)
-            else
-                print("APISIX is running...")
-            end
+        local signone = 0
+        local errno_noproc = 3

Review Comment:
   We can use the constant here: https://luaposix.github.io/luaposix/modules/posix.errno.html



##########
t/cli/test_ops.sh:
##########
@@ -0,0 +1,50 @@
+#!/usr/bin/env bash
+
+#
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements.  See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License.  You may obtain a copy of the License at
+#
+#     http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+. ./t/cli/common.sh
+
+# test cli operations
+git checkout conf/config.yaml
+
+make init
+
+# apisix start - nginx.pid exists but no such process
+fakepid=9999

Review Comment:
   In fact, there is already a test to cover it: https://github.com/apache/apisix/blob/5da97515cff8da8fa0f1c8ab9ee55662bd871f13/t/cli/test_main.sh#L698



-- 
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: notifications-unsubscribe@apisix.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org