[Home]

Summary:ASTERISK-00895: [patch] safe_asterisk with init script does not restart asterisk on crash
Reporter:unknownLabels:
Date Opened:2004-01-22 08:53:20.000-0600Date Closed:2011-06-07 14:10:03
Priority:MinorRegression?No
Status:Closed/CompleteComponents:Core/Configuration
Versions:Frequency of
Occurrence
Related
Issues:
Environment:Attachments:( 0) safe_asterisk.diff
Description:On a fedora core 1 machine using the init script generated by doing a 'make config', asterisk does not restart (or notify) if there is a crash.

I have traced this down to the daemon function in /etc/init.d/functions.  From the command line, if you run safe_asterisk by calling 'initlog -c safe_asterisk' as this function does, it does not restart after a crash.  If you modify daemon() as such:
...
       if [ "$*" != "safe_asterisk" ];then
       if [ -z "$user" ]; then
          $nice initlog $INITLOG_ARGS -c "$*"
       else
          $nice initlog $INITLOG_ARGS -c "su -s /bin/bash - $user -c \"$*\""
       fi
       else
          $nice "$*"
       fi
       [ "$?" -eq 0 ] && success $"$base startup" || failure $"$base startup"
}

Then everything works fine.  initlog works fine also if you use 'initlog -r' instead of 'initlog -c'.
Comments:By: () 2004-01-22 08:57:01.000-0600

This is with version 0.7.1

By: zoa (zoa) 2004-01-22 12:03:13.000-0600

i also noticed that asterisk sometimes crashed without restarting while using safe_asterisk.

(It crashed due to an error i made in a custom app).

By: Paul Cadach (pcadach) 2004-02-08 00:43:37.000-0600

Just remove '&' in the script when asterisk starts with console on tty9:
                       asterisk ${ASTARGS} > /dev/${TTY} < /dev/${TTY}

By: zoa (zoa) 2004-02-08 07:10:17.000-0600

can you provide us with a diff -u ?

By: Paul Cadach (pcadach) 2004-02-08 11:58:01.000-0600

I can't find safe_asterisk in the current CVS. Attached diff is for asterisk-0.5.0 distribution (I don't think that was modified too much in any future releases).

By: Brian West (bkw918) 2004-02-08 14:38:34.000-0600

its in the contrib directory now

By: () 2004-02-18 16:30:43.000-0600

This does not fix the problem for me.  With or without the &, running safe_asterisk from the command prompt works like a charm.  Running it from the init script, I can see everything running on tty9, but when I kill asterisk it does not restart.

By: heison (heison) 2004-03-21 22:17:17.000-0600

is this still a problem? please confirm with the CVS version you're using.

By: () 2004-03-24 12:22:02.000-0600

I am using CVS-03/13/04-14:00:27 and it is still a problem.  If I run safe_asterisk manually from the command line, it restarts fine.  If I run it via the standard /etc/init.d/asterisk script, it doesn't restart at all (and safe_asterisk itself terminates if i kill -11 the asterisk process).  Making the change listed above (removing &) does not fix for me.

The rc.d script just doesn't seem to play nice with redhat's daemon function (specifically the initlog -c).

By: Brian West (bkw918) 2004-04-28 18:54:12

Wonder if its a path issue.

By: twisted (twisted) 2004-05-01 22:59:44

Closing this due to the fact it is a RH only issue, and the code is contributed, not part of */zaptel/libpri/etc....   if you want to paste the diff into the wiki as a possible solution for RH systems, feel free.