Skip to content

no request found #272

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

Open
ajayNegiCodes opened this issue Jan 17, 2024 · 1 comment
Open

no request found #272

ajayNegiCodes opened this issue Jan 17, 2024 · 1 comment

Comments

@ajayNegiCodes
Copy link

ajayNegiCodes commented Jan 17, 2024

This code being executed from the context of init_by_lua_file is giving the below error:

local red = redis:new()

Looking at this - https://github.com/openresty/lua-resty-redis#limitations

It says:

This library cannot be used in code contexts like init_by_lua*, set_by_lua*, 
log_by_lua*, and header_filter_by_lua* where the ngx_lua cosocket API is not available.

I want to execute a lua script when the nginx server starts. And usually that's done through init_by_lua_block/init_by_lua_file directives. How can I achieve that purpose here?

@zhuizhuhaomeng
Copy link
Contributor

You cannt do that in init_by_lua_block.

You can save your code into a file and then run with resty cmd.
In the Lua code, you can save the resource into a file.
And then load the resource from the file in the previous step.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants