crossroads

Git mirror of https://crossroads.e-tunity.com/
git clone git://git.finwo.net/app/crossroads
Log | Files | Refs | LICENSE

commit 53ff91b87b0a08a521ed7e694dc9def36efd8e6c
parent 65b5c15aaf415b2fa3e1b224dd6ab8ee5d8d28d5
Author: finwo <finwo@pm.me>
Date:   Sat,  3 Jan 2026 19:37:07 +0100

2.40

Diffstat:
MChangeLog | 9++++++++-
MMakefile | 2+-
Mdoc/xr.odt | 0
Mdoc/xr.pdf | 0
Mdoc/xrctl.1 | 2+-
Mdoc/xrctl.xml.5 | 53+++++++++++++++++++++++++++++------------------------
Mtest/sampleconf.xml | 34++++++++++++++++++++--------------
Mxr/netbuffer/netread.cc | 11+++++++----
Mxr/sys/socketclose.cc | 2+-
Mxrctl/xrctl | 43++++++++++++++++++++++++++-----------------
10 files changed, 93 insertions(+), 63 deletions(-)

diff --git a/ChangeLog b/ChangeLog @@ -1,3 +1,10 @@ +2.40 [KK 2009-01-03] +- Netbuffer::read() failures are no longer logged as errors, but as + verbose messages. +- XML configuration now supports "logger" to redefine logger program. +- Small changes to xrctl: ps command is auto-guessed when not + specified in the XML configuration. + 2.39 [KK 2008-12-04] - Added Httpbuffer::reset() - The HTTP dispatcher will show back end error returns (when the HTTP @@ -8,7 +15,7 @@ - Exceptions during the sending of an error page in HTTP mode are discarded, no longer logged. - Mutex lock added around thread startups (see Thread::start()), when - requested so in sys/sys. + requested soq in sys/sys. - Mutex locks around malloc()/realloc(), when requested so in sys/sys. - Fixed possible socket leak in TcpDispatcher::execute(). The back end socket might not have been closed when the dispatch phase crashed. diff --git a/Makefile b/Makefile @@ -1,7 +1,7 @@ # Top-level Makefile for XR # ------------------------- -VER = 2.39 +VER = 2.40 PREFIX = $(DESTDIR)/usr BINDIR = $(PREFIX)/sbin MANDIR = $(PREFIX)/share/man diff --git a/doc/xr.odt b/doc/xr.odt Binary files differ. diff --git a/doc/xr.pdf b/doc/xr.pdf Binary files differ. diff --git a/doc/xrctl.1 b/doc/xrctl.1 @@ -1,4 +1,4 @@ -.TH "XRCTL" "1" "Nov 7, 2008" "Crossroads" "Man Page" +.TH "XRCTL" "1" "2008,2009" "Crossroads" "Man Page" .SH "NAME" xrctl \- Crossroads control-script diff --git a/doc/xrctl.xml.5 b/doc/xrctl.xml.5 @@ -1,4 +1,4 @@ -.TH "XRCTL.XML" "5" "Nov 8, 2008" "Crossroads" "Man Page" +.TH "XRCTL.XML" "5" "2008,2009" "Crossroads" "Man Page" .SH "NAME" xrctl.xml \- Crossroads control-script configuration file @@ -10,7 +10,6 @@ balancer, then you must configure all services, options and back ends in xrctl.xml. .SH "EXAMPLE" - The following is a configuration example. See the file xr.pdf which is distributed with the sources for a full description. @@ -22,24 +21,30 @@ distributed with the sources for a full description. <!-- General system configuration section --> <system> - <!-- Where do PID files get stored? --> - <piddir>/var/run</piddir> + <!-- Path where the "xr" binary is searched, and zippers as "gzip" + and "bzip2", and the "ps" command. Default is that xrctl + uses $PATH. --> + <path>/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:/opt/local/bin:/opt/local/sbin</path> <!-- "ps" command that shows the PID and command. On Solaris, use - /usr/bin/ps -ef "pid comm" --> - <pscmd>/bin/ps ax -o pid,command</pscmd> + /usr/bin/ps -ef "pid comm" and on Linux/MacOSX use + /bin/ps -ax -o pid,command. Default is that xrctl guesses + the right command. Example: + <pscmd>/bin/ps ax -o pid,command</pscmd> --> <!-- Use "logger" to add output to syslog or not? Logger will be used if the binary can be found, and if uselogger is true. --> <uselogger>true</uselogger> - <!-- If logger is not used: where do logs get written? --> - <logdir>/var/log</logdir> - <!-- If logger is not used: how big may the logs become? - Manipulated during "xrctl rotate". --> - <maxlogsize>100000</maxlogsize> - <!-- If logger is not used: how many history logs to keep? --> - <loghistory>10</loghistory> - <!-- Path where the "xr" binary is searched, and zippers as "gzip" - and "bzip2" --> - <path>/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:/opt/local/bin:/opt/local/sbin</path> + <!-- The default logger is the program "logger". Redefine here if + you like, for example to a piping logrotate program. Example: + <logger>clpipe /var/log/xr.clog</logger> + The default <logger> command is: logger -t xr.{service} --> + <!-- If logger is NOT used, xrctl will manage log output. In that + case, specify the following: + - Where do logs get written? + <logdir>/var/log</logdir> + - How big may the logs become? Manipulated during "xrctl rotate". + <maxlogsize>100000</maxlogsize> + - How many history logs to keep? + <loghistory>10</loghistory> --> </system> <!-- Service descriptions: This section defines all balancing @@ -131,7 +136,7 @@ distributed with the sources for a full description. softmaxconnrate (here: 150), then each connection is delayed for defertime microsecs (here: 1.000.000, one sec). - Finally, the entire balancer will be allowed to serve up + Finally, the entire balancer will be allowed to serve up to 400 simultaneous connections. --> <timeinterval>2</timeinterval> @@ -140,13 +145,13 @@ distributed with the sources for a full description. <defertime>1000000</defertime> <maxconnections>400</maxconnections> - <!-- Let's add some more protection. When a user exceeds their - hard maxconn rate, "/path/to/program" will be invoked - with the IP as argument. That program may eg. call - iptables to block the client. There is also a tag - softmaxconnexcess (not shown here). --> - <hardmaxconnexcess>/path/to/program</hardmaxconnexcess> - + <!-- Let's add some more protection. When a user exceeds their + hard maxconn rate, "/path/to/program" will be invoked + with the IP as argument. That program may eg. call + iptables to block the client. There is also a tag + softmaxconnexcess (not shown here). --> + <hardmaxconnexcess>/path/to/program</hardmaxconnexcess> + </dosprotection> <http> diff --git a/test/sampleconf.xml b/test/sampleconf.xml @@ -5,24 +5,30 @@ <!-- General system configuration section --> <system> - <!-- Where do PID files get stored? --> - <piddir>/var/run</piddir> + <!-- Path where the "xr" binary is searched, and zippers as "gzip" + and "bzip2", and the "ps" command. Default is that xrctl + uses $PATH. --> + <path>/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:/opt/local/bin:/opt/local/sbin</path> <!-- "ps" command that shows the PID and command. On Solaris, use - /usr/bin/ps -ef "pid comm" --> - <pscmd>/bin/ps ax -o pid,command</pscmd> + /usr/bin/ps -ef "pid comm" and on Linux/MacOSX use + /bin/ps -ax -o pid,command. Default is that xrctl guesses + the right command. Example: + <pscmd>/bin/ps ax -o pid,command</pscmd> --> <!-- Use "logger" to add output to syslog or not? Logger will be used if the binary can be found, and if uselogger is true. --> <uselogger>true</uselogger> - <!-- If logger is not used: where do logs get written? --> - <logdir>/var/log</logdir> - <!-- If logger is not used: how big may the logs become? - Manipulated during "xrctl rotate". --> - <maxlogsize>100000</maxlogsize> - <!-- If logger is not used: how many history logs to keep? --> - <loghistory>10</loghistory> - <!-- Path where the "xr" binary is searched, and zippers as "gzip" - and "bzip2" --> - <path>/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:/opt/local/bin:/opt/local/sbin</path> + <!-- The default logger is the program "logger". Redefine here if + you like, for example to a piping logrotate program. Example: + <logger>clpipe /var/log/xr.clog</logger> + The default <logger> command is: logger -t xr.{service} --> + <!-- If logger is NOT used, xrctl will manage log output. In that + case, specify the following: + - Where do logs get written? + <logdir>/var/log</logdir> + - How big may the logs become? Manipulated during "xrctl rotate". + <maxlogsize>100000</maxlogsize> + - How many history logs to keep? + <loghistory>10</loghistory> --> </system> <!-- Service descriptions: This section defines all balancing diff --git a/xr/netbuffer/netread.cc b/xr/netbuffer/netread.cc @@ -12,11 +12,14 @@ unsigned Netbuffer::netread (int fd, int timeout) { } check_space(config.buffersize()); - + + // Read from the network. If this fails, don't throw an exception + // because it's quite common (too much logging otherwise). ssize_t nread = read (fd, buf_data + buf_sz, config.buffersize()); - if (nread < 0) - throw static_cast<Error>("Read failed on fd ") + fd + ": " + - strerror(errno); + if (nread < 0) { + msg(Mstr("Read failed on fd ") + fd + ": " + strerror(errno)); + return 0; + } buf_sz += nread; if (config.debug() && nread) { diff --git a/xr/sys/socketclose.cc b/xr/sys/socketclose.cc @@ -9,7 +9,7 @@ void socketclose (int fd) { if (config.fastclose()) { struct linger l; l.l_onoff = 1; - l.l_linger = 0; + l.l_linger = 2; setsockopt (fd, SOL_SOCKET, SO_LINGER, &l, sizeof(l)); } close (fd); diff --git a/xrctl/xrctl b/xrctl/xrctl @@ -50,14 +50,28 @@ my $xp = new XMLParser($xml); # Load up the system config. my %sysconf; my $sysxp = new XMLParser($xp->data('system')); -for my $tag qw(piddir pscmd uselogger logdir maxlogsize loghistory path) { +for my $tag qw(pscmd logger uselogger logdir + maxlogsize loghistory path) { $sysconf{$tag} = $sysxp->data($tag); - msg("System config $tag: $sysconf{$tag}\n"); + msg("System config $tag: $sysconf{$tag}\n") if ($sysconf{$tag} ne ''); } if ($sysconf{path} eq '') { msg ("No path in configuration, using environment\n"); $sysconf{path} = $ENV{PATH}; } +if ($sysconf{logger} ne 'logger') { + msg ("Using non-default logger\n"); + $default_logger = $sysconf{logger}; +} +if ($sysconf{pscmd} eq '') { + $sysconf{pscmd} = xfind_bin('ps'); + if (`uname` =~ /SunOS/) { + $sysconf{pscmd} .= ' -ef pid,comm'; + } else { + $sysconf{pscmd} .= ' ax -o pid,command'; + } +} +msg ("PS command: $sysconf{pscmd}\n"); # Load up the service names. my @service_name; @@ -105,7 +119,6 @@ sub cmd_list { for my $s (@_) { print ("Service: $s\n"); print (" Process name : ", process_name($s), "\n"); - print (" PID file : ", pid_file($s), "\n"); print (" Logging : ", log_file($s), "\n"); print (" XR command : ", xr_command($s), "\n"); } @@ -348,10 +361,12 @@ sub msg { # Find a binary along the path sub find_bin { my $bin = shift; + my @parts = split (/\s/, $bin); for my $d (split (/:/, $sysconf{path})) { - if (-x "$d/$bin") { - msg ("Binary '$bin' found as '$d/$bin'\n"); - return ("$d/$bin"); + if (-x "$d/$parts[0]") { + msg ("Binary '$parts[0]' found as '$d/$parts[0]'\n"); + $parts[0] = "$d/$parts[0]"; + return (join (' ', @parts)); } } msg ("Binary '$bin' not found along $sysconf{path}\n"); @@ -370,20 +385,16 @@ sub process_name { return ("xr-$service"); } -# PID file according to a service name -sub pid_file { - my $service = shift; - return ($sysconf{piddir} . '/' . process_name($service) . '.pid') - if ($sysconf{piddir}); - return (undef); -} - # Log file according to a service name sub log_file { my $service = shift; my $logger = find_bin($default_logger); if (istrue($sysconf{uselogger}) and defined($logger)) { - return ("|$logger -t 'xr-$service'"); + if ($logger eq 'logger') { + return ("|$logger -t 'xr-$service'"); + } else { + return ("|$logger"); + } } else { return ('>' . $sysconf{logdir} . '/' . process_name($service) . '.log'); @@ -411,8 +422,6 @@ sub xr_cmdarr { my @cmd; push (@cmd, "xr-$service"); - - push (@cmd, '--pidfile', pid_file($service)) if (pid_file($service)); push (@cmd, '--prefix-timestamp') if (!istrue($sysconf{uselogger}) or !find_bin('logger'));