summaryrefslogtreecommitdiff
path: root/other/bootstrap_daemon/tox-bootstrapd.sh
diff options
context:
space:
mode:
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