MEDIUM: init: allow directory as argument of -f
If -f argument is a directory add all the files (and only files) it
containes to the config files list.
These files are added in lexical order (respecting LC_COLLATE).
Only files with ".cfg" extension are added.
Only non hidden files (not prefixed with ".") are added.
Symlink are followed.
The -f order is still respected:
$ tree -a rootdir
rootdir
|-- dir1
| |-- .6.cfg
| |-- 1.cfg
| |-- 2
| |-- 3.cfg
| |-- 4.cfg -> 1.cfg
| |-- 5 -> 1.cfg
| |-- 7.cfg -> .
| `-- dir4
| `-- 8.cfg
|-- dir2
| |-- 10.cfg
| `-- 9.cfg
|-- dir3
| `-- 11.cfg
|-- link -> dir3/
|-- root1
|-- root2
`-- root3
$ ./haproxy -C rootdir -f root2 -f dir2 -f root3 -f dir1 \
-f link -f root1
root2
dir2/10.cfg
dir2/9.cfg
root3
dir1/1.cfg
dir1/3.cfg
dir1/4.cfg
link/11.cfg
root1
This can be useful on systemd where you can't change the haproxy
commande line options on service reload.
diff --git a/doc/management.txt b/doc/management.txt
index e0469aa..4f0af10 100644
--- a/doc/management.txt
+++ b/doc/management.txt
@@ -124,26 +124,30 @@
list of options is :
-- <cfgfile>* : all the arguments following "--" are paths to configuration
- file to be loaded and processed in the declaration order. It is mostly
- useful when relying on the shell to load many files that are numerically
- ordered. See also "-f". The difference between "--" and "-f" is that one
- "-f" must be placed before each file name, while a single "--" is needed
- before all file names. Both options can be used together, the command line
- ordering still applies. When more than one file is specified, each file
- must start on a section boundary, so the first keyword of each file must be
- one of "global", "defaults", "peers", "listen", "frontend", "backend", and
- so on. A file cannot contain just a server list for example.
+ file/directory to be loaded and processed in the declaration order. It is
+ mostly useful when relying on the shell to load many files that are
+ numerically ordered. See also "-f". The difference between "--" and "-f" is
+ that one "-f" must be placed before each file name, while a single "--" is
+ needed before all file names. Both options can be used together, the
+ command line ordering still applies. When more than one file is specified,
+ each file must start on a section boundary, so the first keyword of each
+ file must be one of "global", "defaults", "peers", "listen", "frontend",
+ "backend", and so on. A file cannot contain just a server list for example.
- -f <cfgfile> : adds <cfgfile> to the list of configuration files to be
- loaded. Configuration files are loaded and processed in their declaration
- order. This option may be specified multiple times to load multiple files.
- See also "--". The difference between "--" and "-f" is that one "-f" must
- be placed before each file name, while a single "--" is needed before all
- file names. Both options can be used together, the command line ordering
- still applies. When more than one file is specified, each file must start
- on a section boundary, so the first keyword of each file must be one of
- "global", "defaults", "peers", "listen", "frontend", "backend", and so
- on. A file cannot contain just a server list for example.
+ -f <cfgfile|cfgdir> : adds <cfgfile> to the list of configuration files to be
+ loaded. If <cfgdir> is a directory, all the files (and only files) it
+ containes are added in lexical order (respecting LC_COLLATE) to the list of
+ configuration files to be loaded ; only files with ".cfg" extension are
+ added, only non hidden files (not prefixed with ".") are added.
+ Configuration files are loaded and processed in their declaration order.
+ This option may be specified multiple times to load multiple files. See
+ also "--". The difference between "--" and "-f" is that one "-f" must be
+ placed before each file name, while a single "--" is needed before all file
+ names. Both options can be used together, the command line ordering still
+ applies. When more than one file is specified, each file must start on a
+ section boundary, so the first keyword of each file must be one of
+ "global", "defaults", "peers", "listen", "frontend", "backend", and so on.
+ A file cannot contain just a server list for example.
-C <dir> : changes to directory <dir> before loading configuration
files. This is useful when using relative paths. Warning when using