Kozea / Radicale

A simple CalDAV (calendar) and CardDAV (contact) server.
https://radicale.org
GNU General Public License v3.0
3.28k stars 428 forks source link

radicale sometimes crashes on startup #241

Closed rparkins999 closed 9 years ago

rparkins999 commented 9 years ago

It says it crashed with IOError in _open: Errno 13 Permission denied: '/var/log/radicale.log' ls -l /var/log/radicale/radicale.log produces -rw-r----- 1 radicale radicale 49546 Dec 10 18:41 /var/log/radicale/radicale.log which looks OK /etc/init.d/radicale looks like

! /bin/sh

BEGIN INIT INFO

Provides: radicale

Required-Start: $remote_fs

Required-Stop: $remote_fs

Should-Start: $syslog

Default-Start: 2 3 4 5

Default-Stop:

Short-Description: Radicale CalDAV and CardDAV server

Description: Start/Stop the Radicale CalDAV and CardDAV

server, configurable via /etc/default/radicale.

END INIT INFO

Author: Martin Stigge martin@stigge.org

PATH=/sbin:/usr/sbin:/bin:/usr/bin DESC="Radicale CalDAV server" NAME=radicale DAEMON=/usr/bin/$NAME DAEMON_UID=radicale DAEMON_GID=radicale RUNDIR=/var/run/$NAME PIDFILE=$RUNDIR/$NAME.pid CALDIR=/var/lib/$NAME LOGDIR=/var/log/$NAME SCRIPTNAME=/etc/init.d/$NAME

Exit if the package is not installed

[ -x $DAEMON ] || exit 0

Load the VERBOSE setting and other rcS variables

. /lib/init/vars.sh

Define LSB log_* functions.

. /lib/lsb/init-functions

Declare default options

RADICALE_OPTS="--daemon --debug"

Read configuration variable file if it is present

[ -r /etc/default/$NAME ] && . /etc/default/$NAME

Check whether daemon starting is enabled

check_start_daemon() { if [ ! "$ENABLE_RADICALE" = "yes" ]; then [ "$VERBOSE" != no ] && \ log_warning_msg "Not starting radicale, disabled via /etc/default/radicale" return 1 else return 0 fi }

Function that starts the daemon/service

do_start() {

Return

    #   0 if daemon has been started
    #   1 if daemon was already running
    #   2 if daemon could not be started
    for dir in $RUNDIR $CALDIR $LOGDIR; do
            if [ ! -d $dir ]; then
                    mkdir -p $dir
            fi
            if ! dpkg-statoverride --list $dir >/dev/null 2>&1; then
                    chown $DAEMON_UID:$DAEMON_GID $dir
                    chmod g-w,o-rwx $dir
            fi
    done

    start-stop-daemon --start --quiet --pidfile $PIDFILE --startas $DAEMON \
            --name $NAME --test > /dev/null \
            || return 1
    start-stop-daemon --start --quiet --pidfile $PIDFILE --startas $DAEMON \
            --name $NAME --umask 0027 --chuid $DAEMON_UID:$DAEMON_GID -- \
            --pid=$PIDFILE $RADICALE_OPTS \
            || return 2

}

Function that stops the daemon/service

do_stop() {

Return

    #   0 if daemon has been stopped
    #   1 if daemon was already stopped
    #   2 if daemon could not be stopped
    #   other if a failure occurred
    start-stop-daemon --stop --quiet --retry=TERM/30/KILL/5 --pidfile $PIDFILE --name $NAME

}

case "$1" in start) check_start_daemon || exit 0 [ "$VERBOSE" != no ] && log_daemon_msg "Starting $DESC " "$NAME" do_start case "$?" in 0|1) [ "$VERBOSE" != no ] && log_end_msg 0 ;; 2) [ "$VERBOSE" != no ] && log_end_msg 1 ;; esac ;; stop) [ "$VERBOSE" != no ] && log_daemon_msg "Stopping $DESC" "$NAME" do_stop case "$?" in 0|1) [ "$VERBOSE" != no ] && log_end_msg 0 ;; 2) [ "$VERBOSE" != no ] && log_end_msg 1 ;; esac ;; status) status_of_proc "$DAEMON" "$NAME" && exit 0 || exit $? ;; restart|force-reload) log_daemon_msg "Restarting $DESC" "$NAME" do_stop case "$?" in 0|1) check_start_daemon || exit 0 do_start case "$?" in 0) log_end_msg 0 ;; 1) log_end_msg 1 ;; # Old process is still running ) log_end_msg 1 ;; # Failed to start esac ;; )

Failed to stop

            log_end_msg 1
            ;;
    esac
    ;;

*) echo "Usage: $SCRIPTNAME {start|stop|status|restart|force-reload}" >&2 exit 3 ;; esac

: I added the --debug option in the hope of getting some useful diagnostics, but it didn't help, prsemably because it doesn't get to opening the log file. Sometimes it does start successfully. Going to /etc/init.d as root and typing ./radicale start seems to start it up reliably. uname -a says Linux rparkins48 3.13.0-37-generic #64-Ubuntu SMP Mon Sep 22 21:28:38 UTC 2014 x86_64 x86_64 x86_64 GNU/Linux Hardware is a Dell Precision M4800 laptop

rparkins999 commented 9 years ago

Forgot to mention - it's version 0.8 directly installed from the Ubuntu software repository.

untitaker commented 9 years ago

Please use four spaces to indent your code.

liZe commented 9 years ago

Your error is about /var/log/radicale.log, but your init script seems to use /var/log/radicale/radicale.log. There's something wrong in the init script or in your configuration file, but that's probably not Radicale's fault.

rparkins999 commented 9 years ago

"Your error is about /var/log/radicale.log, ..." Well, indeed, that is exactly the problem. WHY is it trying to open /var/log/radicale.log? /etc/radicale/logging says [handler_file]

File handler

class = FileHandler
args = ('/var/log/radicale/radicale.log',)
level = INFO
formatter = full

so it should be trying to open /var/log/radicale/radicale.log and when it starts up successfuly it does so. If it tries to open /var/log/radicale.log after it has set its uid and gid to "radicale", it fails because it doesn't have permission to create a file in /var/log.

As I said, it's a straight installation from the Ubuntu software repository. The only things I've changed are removing the comment from ENABLE_RADICALE=yes in /etc/default/radicale to make it start as a daemon on system startup, and adding --debug in /etc/init.d/radicale (which I did after I first saw the error message) in the hope of getting some useful debug output.

I'm willing to believe that the version in the Ubuntu software repository may be broken, but if so that isn't a problem with my init script or configuration file, but with the officially distributed versions for the Linux distribution that I'm running. I agree that might not be the fault of the radicale developers, but there's no indication where else I should go for help.

Incidentally I noticed that the version of /etc/radicale/logging in github says [handler_file]

File handler

class = FileHandler
args = ('/var/log/radicale',)
formatter = full

which is different from the one as above that I got from the Ubuntu software repository. I tried changing the args line to be like the github version, but that makes radicale fail to start up at all on a reboot, without even an error message.

rparkins999 commented 9 years ago

"Your error is about /var/log/radicale.log, ..." Well, indeed, that is exactly the problem. WHY is it trying to open /var/log/radicale.log? It shouldn't be doing that: the configuration isn't telling it to. See my latest comment.Richard

  From: Guillaume Ayoub <notifications@github.com>

To: Kozea/Radicale Radicale@noreply.github.com Cc: rparkins999 aleph0hpela-bughit@yahoo.co.uk Sent: Monday, 12 January 2015, 18:40 Subject: Re: [Radicale] radicale sometimes crashes on startup (#241)

Your error is about /var/log/radicale.log, but your init script seems to use /var/log/radicale/radicale.log. There's something wrong in the init script or in your configuration file, but that's probably not Radicale's fault.— Reply to this email directly or view it on GitHub.

liZe commented 9 years ago

Do you know which file produces the IOError?

rparkins999 commented 9 years ago

I don't think it says. Next time it happens I'll post the whole crash log.Richard

  From: Guillaume Ayoub <notifications@github.com>

To: Kozea/Radicale Radicale@noreply.github.com Cc: rparkins999 aleph0hpela-bughit@yahoo.co.uk Sent: Monday, 12 January 2015, 21:15 Subject: Re: [Radicale] radicale sometimes crashes on startup (#241)

Do you know which file produces the IOError?— Reply to this email directly or view it on GitHub.

rparkins999 commented 9 years ago

I can't get the Ubuntu failure logger to give me text that I can copy. Attached is a set of screen shots that show what it generates. Curiously, radicale appears to be working after it has reported itself as having crashed.

radicale1 radicale2 radicale3 radicale4