This repository has been archived by the owner on Jan 21, 2022. It is now read-only.
/
router_ctl
69 lines (46 loc) · 2.06 KB
/
router_ctl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
#!/bin/bash
export PATH=/var/vcap/packages/ruby/bin:$PATH
CONF_DIR=/var/vcap/jobs/router/config
RUN_DIR=/var/vcap/sys/run/router
LOG_DIR=/var/vcap/sys/log/router
PIDFILE=$RUN_DIR/router.pid
source /var/vcap/packages/common/utils.sh
case $1 in
start)
pid_guard $PIDFILE "Router"
mkdir -p $RUN_DIR
mkdir -p $LOG_DIR
echo $$ > $PIDFILE
# ephemeral port range
echo "1024 65535" > /proc/sys/net/ipv4/ip_local_port_range
# TCP_FIN_TIMEOUT
# This setting determines the time that must elapse before TCP/IP can release a closed connection and reuse
# its resources. During this TIME_WAIT state, reopening the connection to the client costs less than establishing
# a new connection. By reducing the value of this entry, TCP/IP can release closed connections faster, making more
# resources available for new connections. Addjust this in the presense of many connections sitting in the
# TIME_WAIT state:
echo 5 > /proc/sys/net/ipv4/tcp_fin_timeout
# TCP_TW_RECYCLE
# It enables fast recycling of TIME_WAIT sockets. The default value is 0 (disabled). The sysctl documentation
# incorrectly states the default as enabled. It can be changed to 1 (enabled) in many cases. Known to cause some
# issues with hoststated (load balancing and fail over) if enabled, should be used with caution.
echo 1 > /proc/sys/net/ipv4/tcp_tw_recycle
# TCP_TW_REUSE
# This allows reusing sockets in TIME_WAIT state for new connections when it is safe from protocol viewpoint.
# Default value is 0 (disabled). It is generally a safer alternative to tcp_tw_recycle
echo 1 > /proc/sys/net/ipv4/tcp_tw_reuse
<% if properties.syslog_aggregator %>
/var/vcap/packages/syslog_aggregator/setup_syslog_forwarder.sh $CONF_DIR
<% end %>
exec /var/vcap/packages/router/bin/router \
-c /var/vcap/jobs/router/config/router.yml \
>>$LOG_DIR/router.stdout.log \
2>>$LOG_DIR/router.stderr.log
;;
stop)
kill_and_wait $PIDFILE
;;
*)
echo "Usage: router_ctl {start|stop}"
;;
esac