UlricE / pen

Pen
Other
249 stars 41 forks source link

adding and removing backends onfly #23

Closed EslamElHusseiny closed 8 years ago

EslamElHusseiny commented 8 years ago

Hi, I’ve a few questions regarding penctl. I was trying to modify the list of backends onfly without restarting pen process. I managed to add a new backend by using penctl server option with a server number that doesn’t exist yet, which seems theoretically working fine. But I don’t know how to remove one of the backends on the fly using penctl command. is it possible ?

One more issue I’ve tried to use penctl write command to write the conf file for pen as there is no documentation how to write it, but it didn’t write anything ?!

UlricE commented 8 years ago

You have the adding sorted, just add the new server in an unused slot. To remove a server temporarily, blacklist it. To remove it permanently give it the ip address 0.0.0.0.

To make pen write the configuration, do something like this:

ulric@debtest:~/Git/pen$ ./pen -C ./ctl 127.0.0.1:8000
ulric@debtest:~/Git/pen$ ./penctl ./ctl write cfg
ulric@debtest:~/Git/pen$ ls -l cfg
-rw-r--r-- 1 ulric ulric 359 Jan 16 18:16 cfg
EslamElHusseiny commented 8 years ago

In case of permanent removing this means the backends list will grow by time, especially when you are dealing with a dynamic system like what I'm working with, lots of backends came up with new IPs, and go down after a while. Is there anyway to clean up the backends list ?

UlricE commented 8 years ago

The list doesn't need to grow except to make space for more backends. If you have two servers numbered 0 and 1, add two numbered 2 and 3, remove one numbered 2 and add two numbered 2 and 4, you end up needing five entries.

EslamElHusseiny commented 8 years ago

well actually in dynamic systems that you have lots of instances registering and leaving the system at any time, it would be hassle to manage all the cases, make sense ?

UlricE commented 8 years ago

Not really, it is trivial to query for which servers are running at any time:

ulric@qvp2:~/Git/Linux/pen$ ./pen -C ./pen.ctl 8080 siag.nu:80 siag.nu:80 siag.nu:80
ulric@qvp2:~/Git/Linux/pen$ ./penctl ./pen.ctl servers
0 addr 194.9.95.65 port 80 conn 0 max 0 hard 0 weight 0 prio 0 sx 0 rx 0
1 addr 194.9.95.65 port 80 conn 0 max 0 hard 0 weight 0 prio 0 sx 0 rx 0
2 addr 194.9.95.65 port 80 conn 0 max 0 hard 0 weight 0 prio 0 sx 0 rx 0

I assume that adding and removing servers will be done by a program, in which case the program will either keep track of which servers are in use or query Pen using the method above.

EslamElHusseiny commented 8 years ago

got your point. Thanks