mirror of
https://gitee.com/iresty/apisix.git
synced 2024-12-14 17:01:20 +08:00
fix(standalone): the conf should be available during start (#4027)
This commit is contained in:
parent
a57408d3a3
commit
3cde740838
@ -332,6 +332,16 @@ function _M.new(key, opts)
|
||||
return nil, "missing `key` argument"
|
||||
end
|
||||
|
||||
local ok, ok2, err = pcall(sync_data, obj)
|
||||
if not ok then
|
||||
err = ok2
|
||||
end
|
||||
|
||||
if err then
|
||||
log.error("failed to fetch data from local file ", apisix_yaml_path, ": ",
|
||||
err, ", ", key)
|
||||
end
|
||||
|
||||
ngx_timer_at(0, _automatic_fetch, obj)
|
||||
end
|
||||
|
||||
|
@ -718,8 +718,8 @@ function _M.stream_init_worker()
|
||||
-- for testing only
|
||||
core.log.info("random stream test in [1, 10000]: ", math.random(1, 10000))
|
||||
|
||||
router.stream_init_worker()
|
||||
plugin.init_worker()
|
||||
router.stream_init_worker()
|
||||
|
||||
if core.config == require("apisix.core.config_yaml") then
|
||||
core.config.init_worker()
|
||||
|
@ -267,14 +267,12 @@ function _M.load(config)
|
||||
-- called during synchronizing plugin data
|
||||
http_plugin_names = {}
|
||||
stream_plugin_names = {}
|
||||
for _, conf_value in config_util.iterate_values(config.values) do
|
||||
local plugins_conf = conf_value.value
|
||||
for _, conf in ipairs(plugins_conf) do
|
||||
if conf.stream then
|
||||
core.table.insert(stream_plugin_names, conf.name)
|
||||
else
|
||||
core.table.insert(http_plugin_names, conf.name)
|
||||
end
|
||||
local plugins_conf = config.value
|
||||
for _, conf in ipairs(plugins_conf) do
|
||||
if conf.stream then
|
||||
core.table.insert(stream_plugin_names, conf.name)
|
||||
else
|
||||
core.table.insert(http_plugin_names, conf.name)
|
||||
end
|
||||
end
|
||||
end
|
||||
@ -486,8 +484,10 @@ do
|
||||
automatic = true,
|
||||
item_schema = core.schema.plugins,
|
||||
single_item = true,
|
||||
filter = function()
|
||||
_M.load(plugins_conf)
|
||||
filter = function(item)
|
||||
-- we need to pass 'item' instead of plugins_conf because
|
||||
-- the latter one is nil at the first run
|
||||
_M.load(item)
|
||||
end,
|
||||
})
|
||||
if not plugins_conf then
|
||||
|
Loading…
Reference in New Issue
Block a user