Skip to content

Commit e0fb503

Browse files
committed
fix(cli) re-enable search in $PATH for nginx executable
Since IO.file_exists was being called and of course returned false when called with just `nginx`, the command was never executed, and no chance was given to the shell to try to find the executable in the $PATH. Fix #610
1 parent 3ab10f5 commit e0fb503

File tree

3 files changed

+15
-19
lines changed

3 files changed

+15
-19
lines changed

CHANGELOG.md

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,10 @@ A few fixes requested by the community!
66

77
### Fixed
88

9-
- Plugins
10-
- OAuth2: can detect that the originating protocol for a request was HTTPS through the `X-Forwarded-Proto` header and work behind another reverse proxy (load balancer). [#650](https://github.com/Mashape/kong/pull/650)
11-
- HMAC signature: support for `X-Date` header to sign the request for usage in browsers (since the `Date` header is protected). [#641](https://github.com/Mashape/kong/issues/641)
9+
- Kong properly search the `nginx` in your $PATH variable.
10+
- Plugins:
11+
- OAuth2: can detect that the originating protocol for a request was HTTPS through the `X-Forwarded-Proto` header and work behind another reverse proxy (load balancer). [#650](https://github.com/Mashape/kong/pull/650)
12+
- HMAC signature: support for `X-Date` header to sign the request for usage in browsers (since the `Date` header is protected). [#641](https://github.com/Mashape/kong/issues/641)
1213

1314
## [0.5.1] - 2015/10/13
1415

kong/cli/utils/signal.lua

Lines changed: 10 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -37,33 +37,28 @@ end
3737
-- @param path_to_check Path to the binary
3838
-- @return true or false
3939
local function is_openresty(path_to_check)
40-
if IO.file_exists(path_to_check) then
41-
local cmd = path_to_check.." -v"
42-
local out, code = IO.os_execute(cmd)
43-
if code ~= 0 then
44-
cutils.logger:error_exit(out)
45-
end
46-
return out:match("^nginx version: ngx_openresty/")
47-
or out:match("^nginx version: openresty/")
48-
or out:match("^nginx version: nginx/[%w.%s]+%(nginx%-plus%-extras.+%)")
49-
end
50-
return false
40+
local cmd = path_to_check.." -v"
41+
local out = IO.os_execute(cmd)
42+
return out:match("^nginx version: ngx_openresty/")
43+
or out:match("^nginx version: openresty/")
44+
or out:match("^nginx version: nginx/[%w.%s]+%(nginx%-plus%-extras.+%)")
5145
end
5246

53-
-- Paths where to search for an `nginx` executable in addition to the usual $PATH
47+
-- Preferred paths where to search for an `nginx` executable in priority to the $PATH
5448
local NGINX_BIN = "nginx"
5549
local NGINX_SEARCH_PATHS = {
5650
"/usr/local/openresty/nginx/sbin/",
5751
"/usr/local/opt/openresty/bin/",
5852
"/usr/local/bin/",
59-
"/usr/sbin/"
53+
"/usr/sbin/",
54+
"" -- to check the $PATH
6055
}
6156

6257
-- Try to find an `nginx` executable in defined paths, or in $PATH
6358
-- @return Path to found executable or nil if none was found
6459
local function find_nginx()
65-
for i = 1, #NGINX_SEARCH_PATHS + 1 do
66-
local prefix = NGINX_SEARCH_PATHS[i] and NGINX_SEARCH_PATHS[i] or ""
60+
for i = 1, #NGINX_SEARCH_PATHS do
61+
local prefix = NGINX_SEARCH_PATHS[i]
6762
local to_check = prefix..NGINX_BIN
6863
if is_openresty(to_check) then
6964
return to_check

kong/tools/io.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ function _M.file_size(path)
103103
end
104104

105105
--- Load a yaml configuration file.
106-
-- The return config will get 2 extra fields; `pid_file` of the nginx process
106+
-- The return config will get 2 extra fields; `pid_file` of the nginx process
107107
-- and `dao_config` as a shortcut to the dao configuration
108108
-- @param configuration_path path to configuration file to load
109109
-- @return config Loaded configuration table

0 commit comments

Comments
 (0)