Skip to content
This repository has been archived by the owner on Aug 26, 2022. It is now read-only.

How to add upstream backup server in consul, Does it support? #4

Open
xiaoxuanzi opened this issue Feb 8, 2017 · 2 comments
Open

Comments

@xiaoxuanzi
Copy link

xiaoxuanzi commented Feb 8, 2017

I know how to add upstream server in consul in README:

key: upstreams/node-dev.example
servers: {"enable": true, "servers": [{"host": "127.0.0.1","port": 8001,"weight": 1,"max_fails": 6,"fail_timeout": 30}]}

But i don not know how to add upstream backup servers, and how slardar use backup server when all primary server dowm with the round-robin method?
And i did't find any code to process backup servers.
Can you tell me how? I am wait online! THX!

`local servers = get_servers(consul_cluster, key .. "?raw")
if not servers or not next(servers) then
return false
end

    if not check_servers(servers["servers"]) then
        return false
    end

    local cls = {
        servers = servers["servers"],
        keepalive = tonumber(servers["keepalive"]),
        try =  tonumber(servers["try"]),
    }

    config[skey] = {
        cluster = { cls },
    }`
@xiaoxuanzi xiaoxuanzi changed the title How to add upstream backup server in consul, Does it support it? How to add upstream backup server in consul, Does it support? Feb 9, 2017
@yejingx
Copy link
Contributor

yejingx commented Feb 17, 2017

Sorry for late reply.

how to add upstream backup servers

Checkups support multi-level servers. But Slardar doesn't support by now. You can see only one level is passed to checkups.update_upstream here.

If you want multi-level, maybe you can call checkups.update_upstreams like this:

checkups.update_upstream(skey, {
                    {     -- primary
                        servers = {
                            {host="127.0.0.1", port=12350},
                            {host="127.0.0.1", port=12351},
                        }
                    },
                    {      -- backup
                        servers = {
                            {host="127.0.0.1", port=12352},
                            {host="127.0.0.1", port=12353},
                        }
                    },
            })

Patches welcome.

how slardar use backup server

Slardar use backup servers when all primary servers are down by the same RR policy.

@xiaoxuanzi
Copy link
Author

xiaoxuanzi commented Feb 19, 2017

I'm glad to have received your respone,
thanks a lot.
I want to use Slardar in my project . I have already change some of code in to Slardar adjust my to adapt to the scene in my project. and make Slardar more general.

i am very happy to submit patches in the next months and anticipate your reply.

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

No branches or pull requests

2 participants