apisix-java-plugin-runner icon indicating copy to clipboard operation
apisix-java-plugin-runner copied to clipboard

help request: Java Plugin Runner thorws warning

Open MorganArthur opened this issue 2 years ago • 14 comments

Description

开发java版的外部程序遇到的问题:

程序:apisix是在win11上通过docker-compose安装的容器部署的

java外部插件是clone的demo项目进行改造的

image image

根据文档描述的,我将外部插件编译好的jar可执行文件,上传到了apisix的容器内部 image

之后修改了配置文件并重启了apisix image

然后在Dashboard配置路由信息 image

测试路由转发报错 image 错误日志是这些 image

我不知道是哪一步出了问题,麻烦可以帮忙处理一下吗

Environment

  • APISIX version (run apisix version):2.13-alpine
  • Operating system (run uname -a):
  • OpenResty / Nginx version (run openresty -V or nginx -V):
  • etcd version, if relevant (run curl http://127.0.0.1:9090/v1/server_info):
  • APISIX Dashboard version, if relevant:
  • Plugin runner version, for issues related to plugin runners:
  • LuaRocks version, for installation issues (run luarocks --version):

MorganArthur avatar Jul 14 '22 03:07 MorganArthur

Could you paste the info as text? Some images are too blurred to see.

spacewander avatar Jul 14 '22 05:07 spacewander

2022/07/14 05:46:45 [warn] 58#58: *257 [lua] init.lua:931: respawning new runner..., context: ngx.timer 2022/07/14 05:46:45 [error] 58#2945: lua pipe child execvp() failed while executing java (2: No such file or directory) 2022/07/14 05:46:45 [warn] 58#58: *257 [lua] init.lua:919: runner exited with reason: exit, status: 1, context: ngx.timer 2022/07/14 05:46:45 [warn] 58#58: *257 [lua] init.lua:361: flush_token(): flush conf token in shared dict, context: ngx.timer 2022/07/14 05:46:45 [warn] 58#58: *257 [lua] init.lua:818: flush conf token lrucache, context: ngx.timer 2022/07/14 05:46:45 [warn] 58#58: *257 [lua] init.lua:929: respawn runner 3 seconds later with cmd: ["java","-jar","-Xmx1g","-Xms1g","/usr/local/apisix/external_plugin/apisix-java-plugin-runner.jar"], context: ngx.timer 2022/07/14 05:46:45 [warn] 49#49: *1467811 [lua] init.lua:361: flush_token(): flush conf token in shared dict, context: ngx.timer 2022/07/14 05:46:45 [warn] 49#49: *1467811 [lua] init.lua:818: flush conf token lrucache, context: ngx.timer 2022/07/14 05:46:45 [warn] 51#51: *1467812 [lua] init.lua:361: flush_token(): flush conf token in shared dict, context: ngx.timer 2022/07/14 05:46:45 [warn] 51#51: *1467812 [lua] init.lua:818: flush conf token lrucache, context: ngx.timer 2022/07/14 05:46:45 [warn] 46#46: *1467813 [lua] init.lua:361: flush_token(): flush conf token in shared dict, context: ngx.timer 2022/07/14 05:46:45 [warn] 54#54: *1467814 [lua] init.lua:361: flush_token(): flush conf token in shared dict, context: ngx.timer 2022/07/14 05:46:45 [warn] 46#46: *1467813 [lua] init.lua:818: flush conf token lrucache, context: ngx.timer 2022/07/14 05:46:45 [warn] 54#54: *1467814 [lua] init.lua:818: flush conf token lrucache, context: ngx.timer 2022/07/14 05:46:45 [warn] 45#45: *1467815 [lua] init.lua:361: flush_token(): flush conf token in shared dict, context: ngx.timer 2022/07/14 05:46:45 [warn] 45#45: *1467815 [lua] init.lua:818: flush conf token lrucache, context: ngx.timer 2022/07/14 05:46:45 [warn] 44#44: *1467816 [lua] init.lua:361: flush_token(): flush conf token in shared dict, context: ngx.timer 2022/07/14 05:46:45 [warn] 53#53: *1467817 [lua] init.lua:361: flush_token(): flush conf token in shared dict, context: ngx.timer 2022/07/14 05:46:45 [warn] 44#44: *1467816 [lua] init.lua:818: flush conf token lrucache, context: ngx.timer 2022/07/14 05:46:45 [warn] 52#52: *1467818 [lua] init.lua:361: flush_token(): flush conf token in shared dict, context: ngx.timer 2022/07/14 05:46:45 [warn] 53#53: *1467817 [lua] init.lua:818: flush conf token lrucache, context: ngx.timer 2022/07/14 05:46:45 [warn] 52#52: *1467818 [lua] init.lua:818: flush conf token lrucache, context: ngx.timer 2022/07/14 05:46:45 [warn] 55#55: *1467823 [lua] init.lua:361: flush_token(): flush conf token in shared dict, context: ngx.timer 2022/07/14 05:46:45 [warn] 50#50: *1467824 [lua] init.lua:361: flush_token(): flush conf token in shared dict, context: ngx.timer 2022/07/14 05:46:45 [warn] 50#50: *1467824 [lua] init.lua:818: flush conf token lrucache, context: ngx.timer 2022/07/14 05:46:45 [warn] 55#55: *1467823 [lua] init.lua:818: flush conf token lrucache, context: ngx.timer 2022/07/14 05:46:45 [warn] 47#47: *1467825 [lua] init.lua:361: flush_token(): flush conf token in shared dict, context: ngx.timer 2022/07/14 05:46:45 [warn] 47#47: *1467825 [lua] init.lua:818: flush conf token lrucache, context: ngx.timer 2022/07/14 05:46:45 [warn] 48#48: *1467826 [lua] init.lua:361: flush_token(): flush conf token in shared dict, context: ngx.timer 2022/07/14 05:46:45 [warn] 48#48: *1467826 [lua] init.lua:818: flush conf token lrucache, context: ngx.timer

MorganArthur avatar Jul 14 '22 05:07 MorganArthur

2022/07/14 05:46:45 [error] 58#2945: lua pipe child execvp() failed while executing java (2: No such file or directory)

APISIX cannot find the jar file path, please check the file path inside docker and whether APISIX has permission to read and write the jar file.

tzssangglass avatar Jul 15 '22 03:07 tzssangglass

image

我执行了 chmod 777,restart container again,all the same this error

MorganArthur avatar Jul 15 '22 05:07 MorganArthur

It looks like you wrote the wrong path.

where apisix-java-plugin-runner.jar? /usr/local/apisix-plugin-runner or /usr/local/apisix/external_plugin?

tzssangglass avatar Jul 15 '22 06:07 tzssangglass

/usr/local/apisix-plugin-runner this path is configured by me today,/usr/local/apisix/external_plugin this path was configured by me yesterday. I repackaged the image and configured it again

image

MorganArthur avatar Jul 15 '22 06:07 MorganArthur

I tried it. I put the plugin runner and apimix together to create a new apimix image. There is no problem deploying and using external plug-ins.

However, for apifix image, my external plug-ins may change frequently. What I hope is that apifix does not need to re mirror, but only needs to modify the executable package of the external plug-ins.

I thought of a way to mount the directory of external plug-ins to the outside of the container, and then update the executable package of external plug-ins in this mounted directory. I don't know whether this method is feasible?

MorganArthur avatar Jul 15 '22 07:07 MorganArthur

I thought of a way to mount the directory of external plug-ins to the outside of the container, and then update the executable package of external plug-ins in this mounted directory. I don't know whether this method is feasible?

The unix domain socket will fail via docker mount, so this is not supported.

tzssangglass avatar Jul 15 '22 09:07 tzssangglass

After experiments, I came to a conclusion that I need to create an apifix image containing plugin runner first, then start the image container, and then modify and upload the executable package of plugin runner.

However, this situation is not explained in the document, or I did not find the corresponding document information. I think in the development process, we don't know that we need to develop external plug-ins independently from the beginning, but we will consider developing external plug-ins only when we find that some requirements are not met in the process of using apifix.

Therefore, we first deployed an image container that does not contain plugin runner. Later, when we need to develop external plug-ins, we only need to upload the developed plugin runner to the APIs IX container to use it directly.

I hope the external plug-in development process should be like this. Although repacking the image and starting the container is not a very complicated work, I think it can be saved

MorganArthur avatar Jul 16 '22 01:07 MorganArthur

From the community feedback, it appears that the re-build image deployment method also exists. ref docs: https://github.com/apache/apisix-java-plugin-runner/blob/main/docs/zh/quick-start.md#%E9%83%A8%E7%BD%B2

tzssangglass avatar Jul 17 '22 12:07 tzssangglass

Yes, I mean, the problem I found out was that when I first started using the official Apisix image, if I wanted to use plugin-Runner, I had to rebuild an image that included plugin-Runner before I could use the external plug-in, instead of what the documentation said, Only deploy in the same container. This is not reflected in the documentation.

image

Then, I would like to say that, as mentioned in the documentation, to use plugin-runner, only plugin-runner and Apisix need to be in the same container, so that developers only need to focus on the development of plugin-runner. Plugin-runner's executable package is provided, and there is no need to pay attention to whether plugin-Runner and Apisix have rebuilt the new image

MorganArthur avatar Jul 18 '22 00:07 MorganArthur

Plugin-runner's executable package is provided, and there is no need to pay attention to whether plugin-Runner and Apisix have rebuilt the new image

Would you like to send this topic to the mailing list on [email protected] for discussion about providing an APISIX image with the plugin runnner. (Since this issue is not unique to java runner, plugin runners such as go also do not have mirrors)

tzssangglass avatar Jul 18 '22 00:07 tzssangglass

ok

MorganArthur avatar Jul 18 '22 00:07 MorganArthur

@MorganArthur is there any solution from the apisix ?

lefreet avatar Sep 13 '22 01:09 lefreet

apisix start命令 ,必须在 /usr/local/apisix路径下执行,这样才能生成pid.sock文件!!!! image

tomcmd avatar Mar 22 '24 02:03 tomcmd