Skip to content

Commit

Permalink
Disabled Nagle algorithm in the fault tolerance thread
Browse files Browse the repository at this point in the history
Consolidated example service installation script into one script for standard and EC2 systems. That script needs some testing though and should be considered an experiment.
  • Loading branch information
bwlewis committed Nov 23, 2015
1 parent 524ffa6 commit b164d7d
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 170 deletions.
161 changes: 0 additions & 161 deletions inst/scripts/ec2-redis-worker-installer.sh

This file was deleted.

33 changes: 24 additions & 9 deletions inst/scripts/redis-worker-installer.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,12 @@
# and configures the doRedis init script to start in the usual runlevels.
# Edit the /etc/doRedis.conf file to point to the right Redis server and
# to set other configuration parameters.
#
# Usage:
# sudo ./redis-worker-installer.sh
#
# On AWS EC2 systems, use:
# sudo ./redis-worker-installer.sh EC2

echo "Installing /etc/init.d/doRedis script..."
cat > /etc/init.d/doRedis <<1ZZZ
Expand All @@ -33,16 +39,24 @@ DAEMON=/usr/local/bin/doRedis_worker
DAEMON_ARGS=/etc/doRedis.conf
PIDFILE=/var/run/doRedis.pid
SCRIPTNAME=/etc/init.d/doRedis
EC2=$1
# Define LSB log_* functions.
# Depend on lsb-base (>= 3.0-6) to ensure that this file is present.
. /lib/lsb/init-functions
#
# Function that starts the daemon/service
# Function that starts the daemon/service, optionally initializing
# configuration file from EC2 user data.
#
do_start()
{
if test "\${EC2}" == "EC2"; then
U=\$(wget -O - -q http://169.254.169.254/latest/user-data)
if test -n "\${U}"; then
echo \${U} > /etc/doRedis.conf
fi
fi
sudo -b -n -E -u nobody /usr/local/bin/doRedis_worker /etc/doRedis.conf >/dev/null 2>&1 &
}
Expand Down Expand Up @@ -93,14 +107,15 @@ PORT=\$(cat \$CONF | sed -n /^port:/p | tail -n 1 | sed -e "s/.*:[[:blank:]*]//"
QUEUE=\$(cat \$CONF | sed -n /^queue:/p | tail -n 1 | sed -e "s/.*:[[:blank:]*]//")
LOG=\$(cat \$CONF | sed -n /^log:/p | tail -n 1 | sed -e "s/.*:[[:blank:]*]//")
[ -z "\${N}" ] && N=1
[ -z "\${R}" ] && R=R
[ -z "\${T}" ] && T=5
[ -z "\${I}" ] && I=Inf
[ -z "\${HOST}" ] && HOST=localhost
[ -z "\${PORT}" ] && PORT=6379
# Set default values
[ -z "\${N}" ] && N=2
[ -z "\${R}" ] && R=R
[ -z "\${T}" ] && T=5
[ -z "\${I}" ] && I=Inf
[ -z "\${HOST}" ] && HOST=localhost
[ -z "\${PORT}" ] && PORT=6379
[ -z "\${QUEUE}" ] && QUEUE=RJOBS
[ -z "\${LOG}" ] && LOG=/dev/null
[ -z "\${LOG}" ] && LOG=/dev/null
Terminator ()
{
Expand Down Expand Up @@ -136,7 +151,7 @@ cat > /etc/doRedis.conf << 3ZZZ
# may apper in any order.
#
# Set n to the number of workers to start.
n: 1
n: 2
# Set R to the path to R (default assumes 'R' is in the PATH)
R: R
# Set timeout to wait period after job queue is deleted before exiting
Expand Down
6 changes: 6 additions & 0 deletions src/alive.c
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
#else
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/tcp.h> // TCP_NODELAY
#include <netinet/in.h>
#include <netdb.h>
#include <errno.h>
Expand Down Expand Up @@ -111,6 +112,7 @@ void
tcpconnect (int *s, char *host, int port)
{
struct hostent *h;
socklen_t len;
struct sockaddr_in sa;
int j;

Expand All @@ -136,6 +138,10 @@ tcpconnect (int *s, char *host, int port)
return;
}
}
/* Try to disable Nagle; proceed regardless of success. */
j = 1;
len = sizeof(j);
setsockopt(*s, IPPROTO_TCP, TCP_NODELAY, (const void *)&j, len);
}
#endif

Expand Down

0 comments on commit b164d7d

Please sign in to comment.