xiaokai-wang / nginx-stream-upsync-module

For stream protocol. syncing upstreams from etcd or consul and so on, dynamically updating backend servers attribute, not need to reload nginx for tcp protocol, stream configure.
175 stars 48 forks source link

dump文件没有保存已存在的server #32

Closed TwitchChen closed 5 years ago

TwitchChen commented 5 years ago

请问为什么我upstream内容更新了,但是dump文件中还是第一次启动时候我写的内容,不应该是dump 新的upstream信息么?

dump 文件内容

# cat dump_conf/servers_test.conf 
server 127.0.0.1:80 weight=1 fail_timeout=8 max_fails=3;

upstream 信息

# curl 127.0.0.1:10000/upstream_show
Upstream name: test; Backend server count: 3
server 127.0.0.1:9002 weight=1 max_fails=2 fail_timeout=10s;
server 127.0.0.1:9001 weight=1 max_fails=2 fail_timeout=10s;
server 127.0.0.1:9000 weight=1 max_fails=2 fail_timeout=10s;

nginx conf文件

upstream test {
    upsync 127.0.0.1:8500/v1/kv/upstreams/test/ upsync_timeout=6m upsync_interval=500ms upsync_type=consul strong_dependency=off;
    upsync_dump_path /opt/nginx/conf/db-site/dump_conf/servers_test.conf;

    include /opt/nginx/conf/db-site/dump_conf/servers_test.conf;
}

server {
    listen 10001;
    proxy_connect_timeout 3s;
    proxy_timeout 5s;
    proxy_pass test;
}
server {
    listen 10000;
    upstream_show;
}
gfrankliu commented 5 years ago

nginx user needs to have write permission to the directory "dump_conf"

TwitchChen commented 5 years ago

@gfrankliu thanks, i will have a try. Well, i have another question. when i first start nginx, the nginx conf and dump file just like above.the consul have the kv(like above) already before nginx start. but the nginx upstream have nothing except the dump file server,why? image

TwitchChen commented 5 years ago

I have solved this problem. it's also caused by the nginx file permission .thanks