fukiki commented on a change in pull request #3335:
URL: https://github.com/apache/apisix/pull/3335#discussion_r564157996
##########
File path: Makefile
##########
@@ -193,6 +195,8 @@ install: default
$(INSTALL) -d $(INST_LUADIR)/apisix/plugins/slslog
$(INSTALL) apisix/plugins/slslog/*.lua
$(INST_LUADIR)/apisix/plugins/slslog/
+ cp -r deps/* /usr/local/
Review comment:
All dependencies are installed in INST_LUADIR(/user/share/) by LuaRocks,
but when use luajit, it will be find deps in luajit default path
`/user/local/...`
This is also why changed INST_LIBDIR and INST_LUADIR in
`rockspec/apisix-master-0.rockspec`.
##########
File path: rockspec/apisix-master-0.rockspec
##########
@@ -76,8 +76,8 @@ build = {
install_variables = {
INST_PREFIX="$(PREFIX)",
INST_BINDIR="$(BINDIR)",
- INST_LIBDIR="$(LIBDIR)",
- INST_LUADIR="$(LUADIR)",
+ INST_LIBDIR="/usr/local/lib64/lua/5.1",
Review comment:
Ditto:https://github.com/apache/apisix/pull/3335#discussion_r564157996
##########
File path: bin/apisix
##########
@@ -1,36 +1,40 @@
-#!/usr/bin/env lua
+#!/bin/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.
---
+#
+# 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.
+#
-local pkg_cpath_org = package.cpath
-local pkg_path_org = package.path
+if [ -s './apisix/cli/apisix.lua' ]; then
+ APISIX_LUA=./apisix/cli/apisix.lua
+elif [ -s '/usr/local/share/lua/5.1/apisix/cli/apisix.lua' ]; then
+ APISIX_LUA=/usr/local/share/lua/5.1/apisix/cli/apisix.lua
+else
+ APISIX_LUA=/usr/local/apisix/apisix/cli/apisix.lua
+fi
-local apisix_home = "/usr/local/apisix"
-local pkg_cpath = apisix_home .. "/deps/lib64/lua/5.1/?.so;"
- .. apisix_home .. "/deps/lib/lua/5.1/?.so;;"
-local pkg_path = apisix_home .. "/deps/share/lua/5.1/?.lua;;"
+# find the openresty
+OR_BIN=$(which openresty)
+OR_EXEC=${OR_BIN:-'/usr/local/openresty-debug/bin/openresty'}
--- modify the load path to load our dependencies
-package.cpath = pkg_cpath .. pkg_cpath_org
-package.path = pkg_path .. pkg_path_org
+if [[ -e $OR_EXEC ]]; then
+ # find the luajit binary of openresty
+ LUAJIT_BIN=$(${OR_EXEC} -V 2>&1 | grep prefix | grep -Eo
'prefix=(.*)/nginx\s+--' | grep -Eo '/.*/')luajit/bin/luajit
--- pass path to construct the final result
-local env = require("apisix.cli.env")(apisix_home, pkg_cpath_org, pkg_path_org)
-local ops = require("apisix.cli.ops")
-
-ops.execute(env, arg)
+ # use the luajit of openresty
Review comment:
The absolute path is not portable really.
The installed path of APISIX may not be the lua path, it is a troublesome to
query lua path in bash.
I've ever tried `$LUAJIT_BIN -e "require (\"apisix.cli.apisix\")"`, but it
could not work well in shell script, the argument always error.
Maybe it is better to change `bin/apisix` to lua script?After all, it's
easier to get package.path from lua script.
----------------------------------------------------------------
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.
For queries about this service, please contact Infrastructure at:
[email protected]