Skip to content

Commit

Permalink
CLI: Adding warning message when running APISIX in root path. (apache…
Browse files Browse the repository at this point in the history
  • Loading branch information
sshniro authored and SaberMaster committed Jun 30, 2020
1 parent 2a4ead7 commit 6905e9f
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions bin/apisix
Original file line number Diff line number Diff line change
Expand Up @@ -41,13 +41,18 @@ local pkg_path = apisix_home .. "/deps/share/lua/5.1/apisix/lua/?.lua;"
.. apisix_home .. "/deps/share/lua/5.1/?.lua;;"

-- only for developer, use current folder as working space
local is_root_path = false
local script_path = arg[0]
if script_path:sub(1, 2) == './' then
apisix_home = trim(excute_cmd("pwd"))
if not apisix_home then
error("failed to fetch current path")
end

if string.match(apisix_home, '^/[root][^/]+') then
is_root_path = true
end

pkg_cpath = apisix_home .. "/deps/lib64/lua/5.1/?.so;"
.. apisix_home .. "/deps/lib/lua/5.1/?.so;"
pkg_path = apisix_home .. "/lua/?.lua;"
Expand Down Expand Up @@ -549,6 +554,11 @@ version: print the version of apisix
end

local function init()
if is_root_path then
print('Warning! Running apisix under /root is only suitable for development environments'
.. ' and it is dangerous to do so. It is recommended to run APISIX in a directory other than /root.')
end

-- read_yaml_conf
local yaml_conf, err = read_yaml_conf()
if not yaml_conf then
Expand Down

0 comments on commit 6905e9f

Please sign in to comment.