orlabs / orange

OpenResty/Nginx Gateway for API Monitoring and Management.
http://orange.sumory.com
MIT License
2.31k stars 575 forks source link

master进程启动失败,但worker进程启动正常 #415

Open jimchou800 opened 4 years ago

jimchou800 commented 4 years ago

使用的Orange版本

如v0.8.1

需求或场景
function Orange.init(options)
    options = options or {}
    local store, config
    local status, err = pcall(function()
        local conf_file_path = options.config
        config = config_loader.load(conf_file_path)
        store = require("orange.store.mysql_store")(config.store_mysql)

        loaded_plugins = load_node_plugins(config, store)
        ngx.update_time()
        config.orange_start_at = ngx.now()
    end)

    if not status or err then
        ngx.log(ngx.ERR, "Startup error: " .. err)
        os.exit(1)
    end

    Orange.data = {
        store = store,
        config = config,
    }

    -- init dns_client
    assert(dns_client.init())

    return config, store
end

启动失败则os.exit(1)这里只退出了master进程,worker进程其实还是在运行,导致orange start 和 reload都启动不了,只有把worker进程kill掉

    if not status or err then
        ngx.log(ngx.ERR, "Startup error: " .. err)
        os.exit(1)
    end