mirror of
http://git.haproxy.org/git/haproxy.git/
synced 2025-03-04 02:19:09 +00:00
[MINOR] startup: add an option to change to a new directory
Passing -C <dir> causes haproxy to chdir to <dir> before loading any file. The argument may be passed anywhere on the command line. A typical use case is : $ haproxy -C /etc/haproxy -f global.cfg -f haproxy.cfg
This commit is contained in:
parent
3bafcdc07e
commit
576132e533
@ -220,11 +220,11 @@ void usage(char *name)
|
||||
fprintf(stderr,
|
||||
"Usage : %s [-f <cfgfile>]* [ -vdV"
|
||||
"D ] [ -n <maxconn> ] [ -N <maxpconn> ]\n"
|
||||
" [ -p <pidfile> ] [ -m <max megs> ]\n"
|
||||
" [ -p <pidfile> ] [ -m <max megs> ] [ -C <dir> ]\n"
|
||||
" -v displays version ; -vv shows known build options.\n"
|
||||
" -d enters debug mode ; -db only disables background mode.\n"
|
||||
" -V enters verbose mode (disables quiet mode)\n"
|
||||
" -D goes daemon\n"
|
||||
" -D goes daemon ; -C changes to <dir> before loading files.\n"
|
||||
" -q quiet mode : don't display messages\n"
|
||||
" -c check mode : only check config files and exit\n"
|
||||
" -n sets the maximum total # of connections (%d)\n"
|
||||
@ -357,6 +357,7 @@ void init(int argc, char **argv)
|
||||
int err_code = 0;
|
||||
struct wordlist *wl;
|
||||
char *progname;
|
||||
char *change_dir = NULL;
|
||||
|
||||
/* NB: POSIX does not make it mandatory for gethostname() to NULL-terminate
|
||||
* the string in case of truncation, and at least FreeBSD appears not to do
|
||||
@ -485,6 +486,7 @@ void init(int argc, char **argv)
|
||||
usage(progname);
|
||||
|
||||
switch (*flag) {
|
||||
case 'C' : change_dir = *argv; break;
|
||||
case 'n' : cfg_maxconn = atol(*argv); break;
|
||||
case 'm' : global.rlimit_memmax = atol(*argv); break;
|
||||
case 'N' : cfg_maxpconn = atol(*argv); break;
|
||||
@ -515,6 +517,11 @@ void init(int argc, char **argv)
|
||||
if (LIST_ISEMPTY(&cfg_cfgfiles))
|
||||
usage(progname);
|
||||
|
||||
if (change_dir && chdir(change_dir) < 0) {
|
||||
Alert("Could not change to directory %s : %s\n", change_dir, strerror(errno));
|
||||
exit(1);
|
||||
}
|
||||
|
||||
have_appsession = 0;
|
||||
global.maxsock = 10; /* reserve 10 fds ; will be incremented by socket eaters */
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user