主进程和子进程_APISIX 主进程加载配置

d513ce02cfbf7f0dc02d58a47718b14d.png

配置相关

以下配置均为 APISIX 默认配置。

config-default.yaml

  # dns_resolver:                   # If not set, read from `/etc/resolv.conf`
  #  - 1.1.1.1
  #  - 8.8.8.8
  dns_resolver_valid: 30          # valid time for dns result 30 seconds
  resolver_timeout: 5             # resolver timeout

nginx.conf

nginx.conf 根据 config-default.yaml 配置文件生成。

    init_by_lua_block {
    
        require "resty.core"
        apisix = require("apisix") 

        local dns_resolver = { "183.60.83.19", "183.60.82.98", } 
        local args = {
            dns_resolver = dns_resolver,
        }
        apisix.http_init(args)
    }

配置解析

代码

require "resty.core"

说明

  • 这里显示引用 lua-resy-core 是因为 lua-resty-corelua-nginx-module 中的部分 API 使用 FFI 方式实现,FFI 方式实现的代码可以被 JIT 追踪和优化,性能更高

  • 当前 Openresty 版本是默认使用 lua-resty-core ,可通过以下方法验证 Openresty 版本是否默认使用 lua-resty-core

  1. nginx.conf 未显示指定require "resty.core"

  2. 将环境中的 resty.core 重命名为 resty.core.1mv /usr/local/openresty/lualib/resty/core.lua /usr/local/openresty/lualib/resty/core.lua.1

  3. 启动 openresty ,显示以下错误:

nginx: 
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值