-
Notifications
You must be signed in to change notification settings - Fork 2.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: Use luajit by default when run APISIX CLI #3335
Conversation
Makefile
Outdated
@@ -56,6 +57,9 @@ ifeq ($(LUAROCKS_VER),luarocks 3.) | |||
else | |||
luarocks install rockspec/apisix-master-0.rockspec --tree=deps --only-deps --local | |||
endif | |||
ifneq ($(LUA_VER),Lua 5.1) | |||
sed -i '' -e "s|#!/usr/bin/env lua|#!/usr/bin/env $(LUAJIT_DIR)/bin/luajit|g" ./bin/apisix |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is a hack way. it should not be enough.
here is another way, we can make a try:
#!/bin/sh
# find the openresty, eg: which openresty
...
# find the luajit of openresty
...
# run the CLI of APISIX
$luajit -e '...'
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@membphis
I don't understand very clearly.
Do you mean to create a new shell script to judge whether to use lua5.1 or luajit when running the CLI of APISIX?
It could run the CLI of APISIX selectively: lua ./bin/apisix
or luajit -e ./bin/apisix
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we can use a shell script to write the CLI, it'll to call luajit ./bin/apisix
32bbf86
to
065a44e
Compare
@membphis Could you review commit 065a44 for me? Thank you. By the way, about CI error: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can we put this file bin/apisix.lua
to apisix/cli
?
|
2f04024
to
c0d7384
Compare
ae0ab58
to
e44bdfc
Compare
please merge the code of master branch, CI failed ^_^ |
612eccc
to
519b4f6
Compare
bin/apisix
Outdated
-- modify the load path to load our dependencies | ||
package.cpath = pkg_cpath .. pkg_cpath_org | ||
package.path = pkg_path .. pkg_path_org | ||
if [[ "$LUA_VERSION" =~ "Lua 5.1" && $USE_LUA ]]; then |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is wrong. we should always use luajit
of openresty
bin/apisix
Outdated
-- modify the load path to load our dependencies | ||
package.cpath = pkg_cpath .. pkg_cpath_org | ||
package.path = pkg_path .. pkg_path_org | ||
if [[ "$LUA_VERSION" =~ "Lua 5.1" && $USE_LUA ]]; then |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is wrong. we should always use luajit
of openresty
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if we always use luajit
of openresty , it will be a big chage for old users . so we think maybe we should leave a way for old users ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is fine for the old users, sure for this
519b4f6
to
8911df5
Compare
bin/apisix
Outdated
.. apisix_home .. "/deps/lib/lua/5.1/?.so;;" | ||
local pkg_path = apisix_home .. "/deps/share/lua/5.1/?.lua;;" | ||
# find the openresty | ||
OR_EXEC=$(which openresty) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This step may fail, and we need to do some exception checks.
If the openresty command is not found, you can actively determine whether there is this directory in /usr/local/openresty.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thrown an error if failed to find the openresty
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
208613a
to
5583dac
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, ci failed, need you to process it
@spacewander told me that, this is a bug of openresty do you have any suggestions about this? luajit: lj_asm_x86.h:2819: asm_loop_fixup: Assertion `((intptr_t)target & 15) == 0' failed.
./bin/apisix: line 40: 24266 Aborted (core dumped) $LUAJIT_BIN $APISIX_LUA $*
Error: Process completed with exit code 134. |
The problem occurs with |
About the bug of
|
I think this is fine. you can make a try ^_^ |
@fukiki I think the title can be changed :), we only want to run APISIX CLI with LuaJIT. |
ef3847e
to
70e5eaa
Compare
About the bug of openresty-debug, only using OpenResty 1.19 not Lua 5.1? |
531e38b
to
818fe47
Compare
@membphis I've already done, could you review my pr please? Than you. |
let me take a look. many thx for your nice job |
@fukiki I think we can merge this PR soon ^_^ |
6b70000
to
ac25353
Compare
@membphis The |
ac25353
to
a4fd95e
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, except minor style things
@tokers do you have time to look at this PR?
doc/install-dependencies.md
Outdated
@@ -35,6 +35,8 @@ | |||
|
|||
- If you want use Tengine instead of OpenResty, please take a look at this installation step script [Install Tengine at Ubuntu](../.travis/linux_tengine_runner.sh). | |||
|
|||
- By default Apache APISIX runs with luajit of OpenResty 1.19 (priority) or Lua 5.1. If you run in to an issue `luajit: lj_asm_x86.h:2819: asm_loop_fixup: Assertion '((intptr_t)target & 15) == 0' failed`, it is caused by to the compatibility of OpenResty version. OpenResty 1.19 is recommended, please take a look at this installation step script [linux-install-openresty](../utils/linux-install-openresty.sh). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Apache APISIX runs with luajit
-> Apache APISIX runs with LuaJIT
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@membphis I submitted about the style things.
@@ -35,6 +35,8 @@ ifeq ($(OR_EXEC), ) | |||
ifeq ("$(wildcard /usr/local/openresty-debug/bin/openresty)", "") | |||
@echo "ERROR: OpenResty not found. You have to install OpenResty and add the binary file to PATH before install Apache APISIX." | |||
exit 1 | |||
else |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What about echoing a warn message here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@tokers The warn message will be better, I've submitted.
Just reviewed. |
Signed-off-by: fukiki <one.fhh@163.com>
a4fd95e
to
2a032d6
Compare
@fukiki many thx, merge already |
Signed-off-by: fukiki one.fhh@163.com
What this PR does / why we need it:
When run APISIX, use LuaJIT or Lua 5.1 by default.
If the local lua version is not 5.1, use openresty-luajit as default.
Fix : #3281
Pre-submission checklist: