From 81fe1912a8a6a5f7869a4d6df6c63813e9c1b259 Mon Sep 17 00:00:00 2001 From: Philip O'Toole Date: Thu, 29 Jan 2015 12:54:00 -0800 Subject: [PATCH 1/2] Use start-stop-daemon to launch, if available This allows changing to the influxdb user if necessary. --- scripts/init.sh | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/scripts/init.sh b/scripts/init.sh index 3550361de1..e2b6bce12b 100644 --- a/scripts/init.sh +++ b/scripts/init.sh @@ -27,18 +27,12 @@ if [ -r $DEFAULT ]; then source $DEFAULT fi -if [ "x$NOFILES" == "x" ]; then - NOFILES=0 -fi - -if [ $NOFILES -le 0 ]; then - NOFILES=65536 -fi - if [ "x$STDOUT" == "x" ]; then STDOUT=/dev/null fi +OPEN_FILE_LIMIT=65536 + function pidofproc() { if [ $# -ne 3 ]; then echo "Expected three arguments, e.g. $0 -p pidfile daemon-name" @@ -102,14 +96,20 @@ case $1 in exit 1 # Exit fi fi - # Start the daemon. - if ! ulimit -n $NOFILES >/dev/null 2>&1; then - echo -n "Cannot set the max number of open file descriptors" - exit 1 + + # Bump the file limits, before launching the daemon. These will carry over to + # launched processes. + ulimit -n $OPEN_FILE_LIMIT + if [ $? -ne 0 ]; then + log_failure_msg "set open file limit to $OPEN_FILE_LIMIT" fi log_success_msg "Starting the process" "$name" - nohup $daemon run -config $config -pidfile $pidfile > /dev/null 2>&1 & + if which start-stop-daemon > /dev/null 2>&1; then + start-stop-daemon --chuid influxdb:influxdb --start --quiet --pidfile $pidfile --exec $daemon -- -pidfile $pidfile -config $config > $STDOUT 2>&1 & + else + nohup $daemon run -config $config -pidfile $pidfile > $STDOUT 2>&1 & + fi log_success_msg "$name process was started" ;; From 42d1f4056c4e34ecc7309eec9b1abfbbe7d7dce6 Mon Sep 17 00:00:00 2001 From: Philip O'Toole Date: Thu, 29 Jan 2015 13:27:17 -0800 Subject: [PATCH 2/2] Create 'run' directory tree for influxdb --- package.sh | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/package.sh b/package.sh index 7ece8944d0..9157b6108d 100755 --- a/package.sh +++ b/package.sh @@ -33,6 +33,7 @@ AWS_FILE=~/aws.conf INSTALL_ROOT_DIR=/opt/influxdb +INFLUXDB_RUN_DIR=/var/opt/influxdb CONFIG_ROOT_DIR=/etc/opt/influxdb SAMPLE_CONFIGURATION=etc/config.sample.toml @@ -169,6 +170,9 @@ if ! id influxdb >/dev/null 2>&1; then fi chown -R -L influxdb:influxdb $INSTALL_ROOT_DIR chmod -R a+rX $INSTALL_ROOT_DIR + +mkdir -p $INFLUXDB_RUN_DIR +chown -R -L influxdb:influxdb $INFLUXDB_RUN_DIR EOF echo "Post-install script created successfully at $POST_INSTALL_PATH" }