Skip to content
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

apisix-2.1/apisix/init.lua:89: module 'resty.worker.events' not found: #3207

Closed
jialinks opened this issue Jan 7, 2021 · 13 comments · Fixed by #3220
Closed

apisix-2.1/apisix/init.lua:89: module 'resty.worker.events' not found: #3207

jialinks opened this issue Jan 7, 2021 · 13 comments · Fixed by #3220
Assignees
Labels
bug Something isn't working

Comments

@jialinks
Copy link

jialinks commented Jan 7, 2021

  1. 报错详情:
[error] 6302#6302: init_worker_by_lua error: /root/apisix-2.1/apisix/init.lua:89: module 'resty.worker.events' not found:
        no field package.preload['resty.worker.events']
        no file '/root/apisix-2.1//deps/share/lua/5.1/resty/worker/events.lua'
        no file '/root/apisix-2.1//deps/share/lua/5.1/resty/worker/events/init.lua'
        no file '/root/apisix-2.1/resty/worker/events.lua'
        no file '/root/apisix-2.1/resty/worker/events/init.lua'
        no file '/usr/local/openresty/site/lualib/resty/worker/events.ljbc'
        no file '/usr/local/openresty/site/lualib/resty/worker/events/init.ljbc'
        no file '/usr/local/openresty/lualib/resty/worker/events.ljbc'
        no file '/usr/local/openresty/lualib/resty/worker/events/init.ljbc'
        no file '/usr/local/openresty/site/lualib/resty/worker/events.lua'
        no file '/usr/local/openresty/site/lualib/resty/worker/events/init.lua'
        no file '/usr/local/openresty/lualib/resty/worker/events.lua'
        no file '/usr/local/openresty/lualib/resty/worker/events/init.lua'
        no file './resty/worker/events.lua'
        no file '/usr/local/openresty/luajit/share/luajit-2.1.0-beta3/resty/worker/events.lua'
        no file '/usr/local/share/lua/5.1/resty/worker/events.lua'
        no file '/usr/local/share/lua/5.1/resty/worker/events/init.lua'
        no file '/usr/local/openresty/luajit/share/lua/5.1/resty/worker/events.lua'
        no file '/usr/local/openresty/luajit/share/lua/5.1/resty/worker/events/init.lua'
        no file './resty/worker/events.lua'
        no file '/usr/share/lua/5.1/resty/worker/events.lua'
        no file '/usr/share/lua/5.1/resty/worker/events/init.lua'
        no file '/usr/lib64/lua/5.1/resty/worker/events.lua'
        no file '/usr/lib64/lua/5.1/resty/worker/events/init.lua'
        no file '/root/apisix-2.1//deps/lib64/lua/5.1/resty/worker/events.so'
        no file '/root/apisix-2.1//deps/lib/lua/5.1/resty/worker/events.so'
        no file '/usr/local/openresty/site/lualib/resty/worker/events.so'
        no file '/usr/local/openresty/lualib/resty/worker/events.so'
        no file './resty/worker/events.so'
        no file '/usr/local/lib/lua/5.1/resty/worker/events.so'
        no file '/usr/local/openresty/luajit/lib/lua/5.1/resty/worker/events.so'
        no file '/usr/local/lib/lua/5.1/loadall.so'
        no file './resty/worker/events.so'
        no file '/usr/lib64/lua/5.1/resty/worker/events.so'
        no file '/usr/lib64/lua/5.1/loadall.so'
        no file '/root/apisix-2.1//deps/lib64/lua/5.1/resty.so'
        no file '/root/apisix-2.1//deps/lib/lua/5.1/resty.so'
        no file '/usr/local/openresty/site/lualib/resty.so'
        no file '/usr/local/openresty/lualib/resty.so'
        no file './resty.so'
        no file '/usr/local/lib/lua/5.1/resty.so'
        no file '/usr/local/openresty/luajit/lib/lua/5.1/resty.so'
        no file '/usr/local/lib/lua/5.1/loadall.so'
        no file './resty.so'
        no file '/usr/lib64/lua/5.1/resty.so'
        no file '/usr/lib64/lua/5.1/loadall.so'
stack traceback:
        [C]: in function 'require'
        /root/apisix-2.1/apisix/init.lua:89: in function 'http_init_worker'
        init_worker_by_lua:2: in main chunk
  1. 安装步骤:
  • 安装依赖
# 安装 epel, `luarocks` 需要它
wget http://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm
sudo rpm -ivh epel-release-latest-7.noarch.rpm

# 安装 etcd
wget https://github.com/etcd-io/etcd/releases/download/v3.4.13/etcd-v3.4.13-linux-amd64.tar.gz
tar -xvf etcd-v3.4.13-linux-amd64.tar.gz && \
    cd etcd-v3.4.13-linux-amd64 && \
    sudo cp -a etcd etcdctl /usr/bin/

# 添加 OpenResty 源
sudo yum install yum-utils
sudo yum-config-manager --add-repo https://openresty.org/package/centos/openresty.repo

# 安装 OpenResty 和 编译工具
sudo yum install -y openresty curl git gcc luarocks lua-devel

# 开启 etcd server
nohup etcd &

  • 通过源码包安装
mkdir apisix-2.1
wget https://downloads.apache.org/apisix/2.1/apache-apisix-2.1-src.tgz
tar zxvf apache-apisix-2.1-src.tgz -C apisix-2.1
  • 安装运行时依赖的 Lua 库
cd apisix-2.1
make deps
  • 管理(启动、关闭等)APISIX 服务
# init nginx config file and etcd
$ make init

# start APISIX server
$ make run

# stop APISIX server
$ make stop
@jialinks
Copy link
Author

jialinks commented Jan 7, 2021

系统:CentOS 7.7
本地调用报错信息:
image

@membphis
Copy link
Member

membphis commented Jan 7, 2021

@idbeta @Firstsawyou you can make a check

the steps are fine. If we can not reproduce this issue, can you supply the login information of your machine? @hifou

then we can make a check

@membphis membphis added the checking check first if this issue occurred label Jan 7, 2021
@jialinks
Copy link
Author

jialinks commented Jan 7, 2021

@membphis 非常感谢,我这边可以提供账号,帮忙看一下。

@Firstsawyou
Copy link
Contributor

@idbeta @Firstsawyou you can make a check

the steps are fine. If we can not reproduce this issue, can you supply the login information of your machine? @hifou

then we can make a check

Ok, let me make sure.

@Firstsawyou
Copy link
Contributor

Firstsawyou commented Jan 7, 2021

@hifou
From your error message, found that your apisix project is located in the /root directory. You need to run APISIX in a directory other than /root.

$ make init 

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.
./bin/apisix init_etcd
$ cat ./logs/error.log

init_worker_by_lua error: /root/apisix-2.1/apisix/init.lua:89: module 'resty.worker.events' not found:
        no field package.preload['resty.worker.events']
        no file '/root/apisix-2.1//deps/share/lua/5.1/resty/worker/events.lua'
        no file '/root/apisix-2.1//deps/share/lua/5.1/resty/worker/events/init.lua'
        no file '/root/apisix-2.1/resty/worker/events.lua'
        no file '/root/apisix-2.1/resty/worker/events/init.lua'
        no file '/usr/local/openresty/site/lualib/resty/worker/events.ljbc'
        no file '/usr/local/openresty/site/lualib/resty/worker/events/init.ljbc'

@Firstsawyou
Copy link
Contributor

I think this is a bug, and the apisix service should be prohibited from starting when make run. Because make init has prompted a warning message, but make run is executed normally and apisix starts successfully, which leads to this kind of error message.

@membphis membphis added bug Something isn't working and removed checking check first if this issue occurred labels Jan 7, 2021
@membphis
Copy link
Member

membphis commented Jan 7, 2021

@Firstsawyou would you like to fix this issue? ^_^

@Firstsawyou
Copy link
Contributor

would you like to fix this issue? ^_^

Yes, let me try it.

@Firstsawyou
Copy link
Contributor

Cause of the bug: After APISIX is started, the worker process has the authority of nobody ordinary user. When APISIX is in the /root directory, ordinary users do not have the authority to access the /root directory. Therefore, when APISIX is started, the error log error.log will show the following error message:

init_worker_by_lua error: /root/apisix-2.1/apisix/init.lua:89: module 'resty.worker.events' not found:
        no field package.preload['resty.worker.events']
        no file '/root/apisix-2.1//deps/share/lua/5.1/resty/worker/events.lua'
        no file '/root/apisix-2.1//deps/share/lua/5.1/resty/worker/events/init.lua'
        no file '/root/apisix-2.1/resty/worker/events.lua'
        no file '/root/apisix-2.1/resty/worker/events/init.lua'

@membphis
Copy link
Member

@Firstsawyou do you know why we can capture this error in CLI? Is there any way we can capture this error when the user calls apisix start or make run?

@Firstsawyou
Copy link
Contributor

@Firstsawyou do you know why we can capture this error in CLI? Is there any way we can capture this error when the user calls apisix start or make run?

When calling the make run or apisix start command in the /root directory, we can see this prompt message:

Error: It is forbidden to run APISIX in the /root directory.

and the running of apisix is prohibited.

@membphis
Copy link
Member

When calling the make run or apisix start command in the /root directory, we can see this prompt message:

I want to know why the lack of permissions cannot be detected in the old version of CLI.

How does Kong solve similar problems?

@Firstsawyou
Copy link
Contributor

When calling the make run or apisix start command in the /root directory, we can see this prompt message:

I want to know why the lack of permissions cannot be detected in the old version of CLI.

How does Kong solve similar problems?

This problem exists in the old version.

I need to check the solutions to similar problems in kong.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants