ngx_http_dyups_module
Compilation
The module is not compiled into Tengine by default. It can be enabled with '—with-http_dyups_module'configuration parameter, and enabled lua support with '—with-http_dyups_lua_api'.But it can not be compiled as a '.so'.
file: conf/nginx.conf
- daemon off;
error_log logs/error.log debug;
events {
}
http {
dyups_upstream_conf conf/upstream.conf;
include conf/upstream.conf;
server {
listen 8080;
location / {
proxy_pass http://$host;
}
}
server {
listen 8088;
location / {
echo 8088;
}
}
server {
listen 8089;
location / {
echo 8089;
}
}
server {
listen 8081;
location / {
dyups_interface;
}
}
}
file: conf/upstream.conf
Directives
This directive set the interface location where you can add or delete the upstream list. See the section of Interface for detail.
Syntax: dyups_read_msg_timeout timeDefault: 1sContext: main
This directive set the interval of workers readding the commands from share memory.
This directive set the size of share memory which used to store the commands.
Syntax: dyups_upstream_conf pathDefault: noneContext: main
You will get a better prefomance but it maybe not stable, and you will get a '409' when the update request conflicts with others.
/detail
get all upstreams and their servers/list
get the list of upstreamsupdate one upstream
body
commands;body
server ip:port;/upstream/name
delete one upstream
If you got HTTP_CONFLICT 409
, you need resend the same commands again latter.
The /list and /detail interface will return HTTP_NO_CONTENT 204
when there is no upstream.
Other code means you should modify your commands and call the interface again.
ATTENEION
: You also need a to generate the new config and dump it to Nginx'conf directory.
API
NOTICE:you should add the directive dyups_interface
into your config file to active this feature
- content_by_lua '
local dyups = require "ngx.dyups"
local status, rv = dyups.update("test", [[server 127.0.0.1:8088;]]);
ngx.print(status, rv)
if status ~= 200 then
ngx.print(status, rv)
return
end
ngx.print("update success")
status, rv = dyups.delete("test")
if status ~= 200 then
ngx.print(status, rv)
return
end
ngx.print("delete success")
';
原文: