beardnick commented on issue #7990:
URL: https://github.com/apache/apisix/issues/7990#issuecomment-2136496170
This is my solution.
A new variable called "apisix_core_inited" has been introduced to store the
init process status.
Then the caller can read this variable to determine whether to run its logic
or not.
If you think this solution can work. Please assign this issue to me.
in APISIX.pm
```perl
my $init_by_lua_block = $block->init_by_lua_block // <<_EOC_;
if os.getenv("APISIX_ENABLE_LUACOV") == "1" then
require("luacov.runner")("t/apisix.luacov")
jit.off()
end
require "resty.core"
-- store init status
local apisix_core_inited = false
$extra_init_by_lua
apisix = require("apisix")
local args = {
dns_resolver = $dns_addrs_tbl_str,
}
apisix.http_init(args)
-- set apisix_lua_home into constants module
-- it may be used by plugins to determine the work path of apisix
local constants = require("apisix.constants")
constants.apisix_lua_home = "$apisix_home"
apisix_core_inited = true
$extra_init_by_lua
_EOC_
```
and the caller
```perl
my $extra_init_by_lua = <<_EOC_;
if apisix_core_inited then
-- run before apisix init
else
-- run after apisix init
end
-- run both before and after apisix init
_EOC_
```
@spacewander
--
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.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]