Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Kong can't find nginx #610

@jason-riddle

Description

@jason-riddle

Bug:

Kong is unable to find nginx even though it it defined in my path.

Background:

My path looks like the following

/app/tools/opt/bin:/usr/local/bin:/usr/bin:/bin

and typing in nginx -v returns

nginx version: openresty/1.7.10.2

and the path to nginx is /app/tools/opt/bin/nginx

Potential Culprit?

My knowledge on Lua is limited, but it looks like the paths used to search for the nginx binary are defined here:

https://github.com/Mashape/kong/blob/6cc0d183deceb9c3008553ad3ae144fb2d532c40/kong/cli/utils/signal.lua#L55-L60

local NGINX_SEARCH_PATHS = {
  "/usr/local/openresty/nginx/sbin/",
  "/usr/local/opt/openresty/bin/",
  "/usr/local/bin/",
  "/usr/sbin/"
}

Where the logic to find the nginx binary is done here:

https://github.com/Mashape/kong/blob/6cc0d183deceb9c3008553ad3ae144fb2d532c40/kong/cli/utils/signal.lua#L64-L72

local function find_nginx()
  for i = 1, #NGINX_SEARCH_PATHS + 1 do
    local prefix = NGINX_SEARCH_PATHS[i] and NGINX_SEARCH_PATHS[i] or ""
    local to_check = prefix..NGINX_BIN
    if is_openresty(to_check) then
      return to_check
    end
  end
end

So it looks like only NGINX_SEARCH_PATHS is used to search for the binary and not $PATH? I ask because I see the following comment which makes it seem like $PATH is being searched?

https://github.com/Mashape/kong/blob/6cc0d183deceb9c3008553ad3ae144fb2d532c40/kong/cli/utils/signal.lua#L62

-- Try to find an `nginx` executable in defined paths, or in $PATH

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions