Package: mldonkey-server Version: 2.9.5-2 Severity: normal Tags: patch
TEST Make mistake in /var/lib/mldonkey/downloads.ini like: auto_commit = tfalse RESULTS No error conditions are set, no error messages are printed $ /etc/init.d/mldonkey-server start <No error messages> $ echo $? 0 But, the server dind't actually start: $ tail /var/lib/mldonkey/mlnet.log .2008/12/12 10:49:18 [cO] Started logging... Exception: Invalid_argument("bool_of_string") while handling option:auto_commit in downloads.ini SUMMARY The following patch: - Handles problems better: send errors to stderr, not stdout - Checks the server start by verifying the *.log file; it displays the tail of log and and exist with error as needed Jari -- System Information: Debian Release: lenny/sid APT prefers unstable APT policy: (500, 'unstable') Architecture: i386 (i686) Kernel: Linux 2.6.26-1-686 (SMP w/1 CPU core) Locale: LANG=en_US.UTF-8, LC_CTYPE=en_US.UTF-8 (charmap=UTF-8) Shell: /bin/sh linked to /bin/bash Versions of packages mldonkey-server depends on: ii adduser 3.110 add and remove users and groups ii debconf [debconf-2.0] 1.5.23 Debian configuration management sy ii dpkg 1.14.22 Debian package management system ii libc6 2.7-13 GNU C Library: Shared libraries ii libfreetype6 2.3.7-2 FreeType 2 font engine, shared lib ii libgcc1 1:4.3.2-1 GCC support library ii libgd2-noxpm 2.0.36~rc1~dfsg-3 GD Graphics Library version 2 (wit ii libjpeg62 6b-14 The Independent JPEG Group's JPEG ii libpng12-0 1.2.27-1 PNG library - runtime ii libstdc++6 4.3.2-1 The GNU Standard C++ Library v3 ii mime-support 3.44-1 MIME files 'mime.types' & 'mailcap ii ucf 3.0010 Update Configuration File: preserv ii zlib1g 1:1.2.3.3.dfsg-12 compression library - runtime mldonkey-server recommends no packages. Versions of packages mldonkey-server suggests: pn makejail <none> (no description available) -- debconf information excluded
>From 37f9d9aa969b36548a92fa3c1d29c696ab702e50 Mon Sep 17 00:00:00 2001 From: Jari Aalto <jari.aa...@cante.net> Date: Fri, 12 Dec 2008 10:51:00 +0200 Subject: [PATCH] mldonkey-server.init: better error handling Signed-off-by: Jari Aalto <jari.aa...@cante.net> --- mldonkey-server.init | 42 ++++++++++++++++++++++++++++++++---------- 1 files changed, 32 insertions(+), 10 deletions(-) diff --git a/mldonkey-server.init b/mldonkey-server.init index 03f6372..d91bb8f 100644 --- a/mldonkey-server.init +++ b/mldonkey-server.init @@ -31,6 +31,7 @@ CONFIG=/etc/default/mldonkey-server PIDDIR=/var/run/mldonkey PIDFILE=$PIDDIR/$NAME.pid LOGFILE=/var/log/mldonkey/$NAME.log +SERVERLOG=/var/lib/mldonkey/mlnet.log test -x $WRAPPER || exit 0 @@ -38,6 +39,30 @@ test -e $CONFIG || exit 0 set -e +Warn () +{ + echo "$*" >&2 +} + +Error () +{ + code=$1 + shift + + echo "." + Warn "$DESC: $NAME [ERROR] $@" + exit $code +} + +StartErrorCheck () +{ + if tail -n 2 $SERVERLOG | grep -qi 'aborting' ; then + Warn "$DESC: $NAME [ERROR] server start error" + tail --verbose $SERVERLOG + exit 1 + fi +} + . $CONFIG # /var/run might be on tempfs, see #354701. @@ -73,24 +98,21 @@ fi case "$1" in start|force-start) - echo -n "Starting $DESC: $NAME" + echo "Starting $DESC: $NAME" if [ "x$LAUNCH_AT_STARTUP" != "xtrue" ] && [ "x$1" = "xstart" ]; then - echo " configuration file prevent $NAME to be started (use force-start)." - exit 0 + Error 0 "[ERROR] configuration file prevent $NAME to be started (use force-start)." fi if [ -z "$MLDONKEY_DIR" ] || [ ! -d "$MLDONKEY_DIR" ]; then if [ -z "$MLDONKEY_DIR" ]; then MLDONKEY_DIR="(unset)" fi - echo " $MLDONKEY_DIR is not a valid directory." - exit 1 + Error 1 "$MLDONKEY_DIR is not a valid directory." fi if [ ! -f "$MLDONKEY_DIR/downloads.ini" ]; then - echo " $MLDONKEY_DIR/downloads.ini is not a valid file." - exit 1 + Error 1 "$MLDONKEY_DIR/downloads.ini is not a valid file." fi USER=`/usr/bin/stat --format="%U" "$MLDONKEY_DIR/downloads.ini"` @@ -100,7 +122,8 @@ case "$1" in --pidfile $PIDFILE --background --exec $EXEC \ -- -pid $PIDDIR > $LOGFILE 2>&1 - echo "." + StartErrorCheck + ;; stop) @@ -115,8 +138,7 @@ case "$1" in ;; *) - echo "Usage: $0 {start|stop|restart|force-reload|force-start}" >&2 - exit 1 + Error 1 "Usage: $0 {start|stop|restart|force-reload|force-start}" ;; esac -- 1.5.6.5