From 644452a62fde5fec66dab56c4f47204f42b57bac Mon Sep 17 00:00:00 2001 From: Peter Palfrader Date: Wed, 20 Feb 2008 22:28:09 +0000 Subject: Change the default for MAX_FILEDESCRIPTORS in our init script to depend on the number of system-wide available file descriptors: /proc/sys/fs/file-max is bigger than 100k, set ulimit -n to 32k, if it's smaller than 20k set it to 1024. Big servers at the moment regularly use more than 10k FDs, so our old default of 8k no longer is sufficient. On the other hand we don't want lower end systems to run out of FDs on Tor's account. svn:r13625 --- debian/tor.init | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) (limited to 'debian/tor.init') diff --git a/debian/tor.init b/debian/tor.init index ec5707d7d1..415467e87e 100644 --- a/debian/tor.init +++ b/debian/tor.init @@ -25,7 +25,20 @@ TORPID=$TORPIDDIR/tor.pid DEFAULTSFILE=/etc/default/$NAME WAITFORDAEMON=60 ARGS="" -MAX_FILEDESCRIPTORS=8192 +# Let's try to figure our some sane defaults: +if [ -r /proc/sys/fs/file-max ]; then + system_max=`cat /proc/sys/fs/file-max` + if [ "$system_max" -gt "100000" ] ; then + MAX_FILEDESCRIPTORS=32768 + elif [ "$system_max" -gt "20000" ] ; then + MAX_FILEDESCRIPTORS=8192 + else + MAX_FILEDESCRIPTORS=1024 + fi +else + MAX_FILEDESCRIPTORS=8192 +fi + NICE="" test -x $DAEMON || exit 0 -- cgit v1.2.3-54-g00ecf