summaryrefslogtreecommitdiff
path: root/other/bootstrap_daemon/tox-bootstrapd.sh
diff options
context:
space:
mode:
authorMaxim Biro <nurupo.contributions@gmail.com>2018-10-18 04:23:21 -0400
committerMaxim Biro <nurupo.contributions@gmail.com>2018-11-04 20:10:09 -0500
commit5530e417428c7d5a3165db65ae4dc9f6086b3eb2 (patch)
tree20841e9e9be92bcb0758d19ff7ec6f303a65be2b /other/bootstrap_daemon/tox-bootstrapd.sh
parentb56166f5a6dd2eaef4861c50cbb11b3568aa040e (diff)
Increase NOFILE limit for tox-bootstrapd
tox-bootstrapd can use around 600 TCP sockets during TCP server's normal functioning. Many systems default to having a soft limit of 1024 open file descriptors, which we are close to reaching, so it was suggested we bump that limit to a higher number. iphy suggested increasing it to 32768.
Diffstat (limited to 'other/bootstrap_daemon/tox-bootstrapd.sh')
-rw-r--r--other/bootstrap_daemon/tox-bootstrapd.sh35
1 files changed, 33 insertions, 2 deletions
diff --git a/other/bootstrap_daemon/tox-bootstrapd.sh b/other/bootstrap_daemon/tox-bootstrapd.sh
index d33c38da..5f1e5c68 100644
--- a/other/bootstrap_daemon/tox-bootstrapd.sh
+++ b/other/bootstrap_daemon/tox-bootstrapd.sh
@@ -1,4 +1,4 @@
1#! /bin/sh 1#! /bin/bash
2### BEGIN INIT INFO 2### BEGIN INIT INFO
3# Provides: tox-bootstrapd 3# Provides: tox-bootstrapd
4# Required-Start: $remote_fs $syslog 4# Required-Start: $remote_fs $syslog
@@ -22,6 +22,35 @@ SCRIPTNAME=/etc/init.d/$NAME
22USER=tox-bootstrapd 22USER=tox-bootstrapd
23GROUP=tox-bootstrapd 23GROUP=tox-bootstrapd
24 24
25# Set ulimit -n based on number of fds available.
26# This check is borrowed from Debian's tor package, with a few modifications.
27if [ -r /proc/sys/fs/file-max ]; then
28 system_max=$(cat /proc/sys/fs/file-max)
29 if [ "$system_max" -gt "80000" ] ; then
30 MAX_FILEDESCRIPTORS=32768
31 elif [ "$system_max" -gt "40000" ] ; then
32 MAX_FILEDESCRIPTORS=16384
33 elif [ "$system_max" -gt "20000" ] ; then
34 MAX_FILEDESCRIPTORS=8192
35 elif [ "$system_max" -gt "10000" ] ; then
36 MAX_FILEDESCRIPTORS=4096
37 else
38 MAX_FILEDESCRIPTORS=1024
39 cat << EOF
40
41Warning: Your system has very few file descriptors available in total.
42
43Maybe you should try raising that by adding 'fs.file-max=100000' to your
44/etc/sysctl.conf file. Feel free to pick any number that you deem appropriate.
45Then run 'sysctl -p'. See /proc/sys/fs/file-max for the current value, and
46file-nr in the same directory for how many of those are used at the moment.
47
48EOF
49 fi
50else
51 MAX_FILEDESCRIPTORS=32768
52fi
53
25# Exit if the package is not installed 54# Exit if the package is not installed
26[ -x "$DAEMON" ] || exit 0 55[ -x "$DAEMON" ] || exit 0
27 56
@@ -48,6 +77,8 @@ do_start()
48 fi 77 fi
49 chown $USER:$GROUP $PIDDIR 78 chown $USER:$GROUP $PIDDIR
50 start-stop-daemon --start --quiet --pidfile $PIDFILE --exec $DAEMON --test --chuid $USER > /dev/null || return 1 79 start-stop-daemon --start --quiet --pidfile $PIDFILE --exec $DAEMON --test --chuid $USER > /dev/null || return 1
80 # TCP Server needs to be able to have lots of TCP sockets open.
81 ulimit -n $MAX_FILEDESCRIPTORS
51 start-stop-daemon --start --quiet --pidfile $PIDFILE --exec $DAEMON --chuid $USER -- $DAEMON_ARGS || return 2 82 start-stop-daemon --start --quiet --pidfile $PIDFILE --exec $DAEMON --chuid $USER -- $DAEMON_ARGS || return 2
52} 83}
53 84
@@ -113,4 +144,4 @@ case "$1" in
113 exit 3 144 exit 3
114 ;; 145 ;;
115esac 146esac
116exit 0 \ No newline at end of file 147exit 0