Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 444634 - net-misc/asterisk fails to stop gracefully
Summary: net-misc/asterisk fails to stop gracefully
Status: RESOLVED CANTFIX
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: Current packages (show other bugs)
Hardware: All Linux
: Normal normal (vote)
Assignee: Tony Vroon
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2012-11-25 00:21 UTC by Joseph
Modified: 2013-01-30 16:51 UTC (History)
1 user (show)

See Also:
Package list:
Runtime testing required: ---


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Joseph 2012-11-25 00:21:33 UTC
I'm running asterisk on a small box, Intel-R-_Atom-TM-_CPU_330_@_1.60GHz
and on AMD 8-Core Server
When asterisk runs for a week or so and I try to restart the asterisk it fails.

/etc/init.d/asterisk restart
 * Caching service dependencies ...           [ ok ]
 * Killing wrapper script ...                 [ ok ]
 * Stopping asterisk PBX gracefully ...

* Waiting for asterisk to shutdown .............................................................
 * Failed.

When I run /etc/init.d/asterisk status
I get: "* status: started"

At this point I have to kill the process ID
"zap" it (/etc/init.d/asterisk zap)
and restart it.

Why asteriks can not shut down properly?
How can I monitor this process and restart it?

Most of the time I can "stop, start and restart" asterisk without a problems it only happens when asterisk has been rinning for few days or a week. 

Reproducible: Always




Portage 2.1.11.31 (default/linux/amd64/10.0/desktop, gcc-4.5.4, glibc-2.15-r3, 3.1.6-gentoo x86_64)
=================================================================
System uname: Linux-3.1.6-gentoo-x86_64-AMD_FX-tm-8150_Eight-Core_Processor-with-gentoo-2.1
Timestamp of tree: Sat, 17 Nov 2012 03:00:01 +0000
ld GNU ld (GNU Binutils) 2.22
app-shells/bash:          4.2_p37
dev-java/java-config:     2.1.11-r3
dev-lang/python:          2.7.3-r2, 3.1.5, 3.2.3
dev-util/cmake:           2.8.9
dev-util/pkgconfig:       0.27.1
sys-apps/baselayout:      2.1-r1
sys-apps/openrc:          0.9.8.4
sys-apps/sandbox:         2.5
sys-devel/autoconf:       2.13, 2.68
sys-devel/automake:       1.11.6
sys-devel/binutils:       2.22-r1
sys-devel/gcc:            4.5.4
sys-devel/gcc-config:     1.7.3
sys-devel/libtool:        2.4-r1
sys-devel/make:           3.82-r3
sys-kernel/linux-headers: 3.4-r2 (virtual/os-headers)
sys-libs/glibc:           2.15-r3
Repositories: gentoo paddymac
ACCEPT_KEYWORDS="amd64"
ACCEPT_LICENSE="* -@EULA googleearth PUEL dlj-1.1 Oracle-BCLA-JavaSE"
CBUILD="x86_64-pc-linux-gnu"
CFLAGS="-march=native -Os -pipe"
CHOST="x86_64-pc-linux-gnu"
CONFIG_PROTECT="/etc /usr/lib64/fax /usr/share/gnupg/qualified.txt /usr/share/openvpn/easy-rsa /var/spool/fax/etc"
CONFIG_PROTECT_MASK="/etc/ca-certificates.conf /etc/env.d /etc/env.d/java/ /etc/fonts/fonts.conf /etc/gconf /etc/gentoo-release /etc/php/apache2-php5.3/ext-active/ /etc/php/apache2-php5.4/ext-active/ /etc/php/cgi-php5.3/ext-active/ /etc/php/cgi-php5.4/ext-active/ /etc/php/cli-php5.3/ext-active/ /etc/php/cli-php5.4/ext-active/ /etc/revdep-rebuild /etc/sandbox.d /etc/terminfo /etc/texmf/language.dat.d /etc/texmf/language.def.d /etc/texmf/updmap.d /etc/texmf/web2c"
CXXFLAGS="-march=native -Os -pipe"
DISTDIR="/usr/portage/distfiles"
EMERGE_DEFAULT_OPTS="--autounmask=n"
FCFLAGS="-O2 -pipe"
FEATURES="assume-digests binpkg-logs config-protect-if-modified distlocks ebuild-locks fixlafiles merge-sync news parallel-fetch protect-owned sandbox sfperms strict unknown-features-warn unmerge-logs unmerge-orphans userfetch"
FFLAGS="-O2 -pipe"
GENTOO_MIRRORS="http://mirror.csclub.uwaterloo.ca/gentoo-distfiles/ ftp://mirror.csclub.uwaterloo.ca/gentoo-distfiles/ http://linux.rz.ruhr-uni-bochum.de/download/gentoo-mirror/ ftp://linux.rz.ruhr-uni-bochum.de/gentoo-mirror/ ftp://ftp.spline.inf.fu-berlin.de/mirrors/gentoo/ http://ftp.spline.inf.fu-berlin.de/mirrors/gentoo/"
LANG="en_US.UTF-8"
LC_ALL="en_US.UTF-8"
LDFLAGS="-Wl,-O1 -Wl,--as-needed"
LINGUAS="en"
MAKEOPTS="-j9 --load-average=8"
PKGDIR="/usr/portage/packages"
PORTAGE_CONFIGROOT="/"
PORTAGE_RSYNC_OPTS="--recursive --links --safe-links --perms --times --compress --force --whole-file --delete --stats --human-readable --timeout=180 --exclude=/distfiles --exclude=/local --exclude=/packages"
PORTAGE_TMPDIR="/var/tmp"
PORTDIR="/usr/portage"
PORTDIR_OVERLAY="/var/lib/layman/paddymac"
SYNC="rsync://10.0.0.103/gentoo-portage"
USE="X a52 aac acpi alsa amd64 apache2 bluetooth branding bzip2 cairo cdda cdr cgi cleartype cli consolekit consolkit corefonts cracklib crypt cups cxx dbus dri dts dvd dvdr emboss encode exif fam firefox flac foomaticdb fortran gdbm gif gimp gimpprint gpm gtk iconv ipv6 java jpeg kpathsea lcms ldap libnotify lock mad mmx mng modules mp3 mp4 mpeg mudflap multilib mysql ncurses nls nptl ogg opengl openmp pam pango pcre pdf png policykit ppds pppd qt3support readline scanner sdl session spell sse sse2 ssl startup-notification svg tcpd tetexspell thunar tiff truetype type1 udev udisks unicode upower usb vorbis wxwidgets x264 xcb xml xv xvid zlib" ALSA_CARDS="ali5451 als4000 atiixp atiixp-modem bt87x ca0106 cmipci emu10k1x ens1370 ens1371 es1938 es1968 fm801 hda-intel intel8x0 intel8x0m maestro3 trident usb-audio via82xx via82xx-modem ymfpci" ALSA_PCM_PLUGINS="adpcm alaw asym copy dmix dshare dsnoop empty extplug file hooks iec958 ioplug ladspa lfloat linear meter mmap_emul mulaw multi null plug rate route share shm softvol" APACHE2_MODULES="authn_core authz_core socache_shmcb unixd actions alias auth_basic authn_alias authn_anon authn_dbm authn_default authn_file authz_dbm authz_default authz_groupfile authz_host authz_owner authz_user autoindex cache cgi cgid dav dav_fs dav_lock deflate dir disk_cache env expires ext_filter file_cache filter headers include info log_config logio mem_cache mime mime_magic negotiation rewrite setenvif speling status unique_id userdir usertrack vhost_alias" CALLIGRA_FEATURES="kexi words flow plan sheets stage tables krita karbon braindump" CAMERAS="ptp2" COLLECTD_PLUGINS="df interface irq load memory rrdtool swap syslog" ELIBC="glibc" GPSD_PROTOCOLS="ashtech aivdm earthmate evermore fv18 garmin garmintxt gpsclock itrax mtk3301 nmea ntrip navcom oceanserver oldstyle oncore rtcm104v2 rtcm104v3 sirf superstar2 timing tsip tripmate tnt ubx" INPUT_DEVICES="evdev" KERNEL="linux" LCD_DEVICES="bayrad cfontz cfontz633 glk hd44780 lb216 lcdm001 mtxorb ncurses text" LIBREOFFICE_EXTENSIONS="presenter-console presenter-minimizer" LINGUAS="en" PHP_TARGETS="php5-3 php5-4" PYTHON_TARGETS="python2_7 python3_2" RUBY_TARGETS="ruby18 ruby19" SANE_BACKENDS="epson2" USERLAND="GNU" VIDEO_CARDS="nvidia" XTABLES_ADDONS="quota2 psd pknock lscan length2 ipv4options ipset ipp2p iface geoip fuzzy condition tee tarpit sysrq steal rawnat logmark ipmark dhcpmac delude chaos account"
Unset:  CPPFLAGS, CTARGET, INSTALL_MASK, PORTAGE_BUNZIP2_COMMAND, PORTAGE_COMPRESS, PORTAGE_COMPRESS_FLAGS, PORTAGE_RSYNC_EXTRA_OPTS, USE_PYTHON
Comment 1 Tony Vroon gentoo-dev 2012-11-25 10:39:39 UTC
What Asterisk branch is this please? 1.8, 10 or 11?

What exact ebuild version did it come from? To confirm, your toolchain is not controversial and neither are your CFLAGS (I would recommend -O2 over -Os for nearly all use cases, but it should not cause breakage).

I have the environment for your 8-core box now, with thanks, could I also see the Atom?
Comment 2 Joseph 2012-11-25 17:34:23 UTC
On Atom CPU and AMD-8 Core I'm using: asterisk- 1.8.15.1
I will chage the CFLAGS to -O2 on AMD but I doubt it will make any difference.

Here is the environment from Atom CPU (CFLAGS is -O2).

Portage 2.1.11.9 (default/linux/amd64/10.0, gcc-4.5.4, glibc-2.15-r2, 2.6.36-gentoo-r5 x86_64)
=================================================================
System uname: Linux-2.6.36-gentoo-r5-x86_64-Intel-R-_Atom-TM-_CPU_330_@_1.60GHz-with-gentoo-2.1
Timestamp of tree: Wed, 10 Oct 2012 23:15:01 +0000
ccache version 3.1.7 [disabled]
app-shells/bash:          4.2_p37
dev-java/java-config:     2.1.11-r3
dev-lang/python:          2.7.3-r2, 3.1.5, 3.2.3
dev-util/ccache:          3.1.7
dev-util/cmake:           2.8.9
dev-util/pkgconfig:       0.27.1
sys-apps/baselayout:      2.1-r1
sys-apps/openrc:          0.9.8.4
sys-apps/sandbox:         2.5
sys-devel/autoconf:       2.13, 2.68
sys-devel/automake:       1.11.6
sys-devel/binutils:       2.22-r1
sys-devel/gcc:            4.5.4
sys-devel/gcc-config:     1.7.3
sys-devel/libtool:        2.4-r1
sys-devel/make:           3.82-r3
sys-kernel/linux-headers: 3.4-r2 (virtual/os-headers)
sys-libs/glibc:           2.15-r2
Repositories: gentoo x-portage
ACCEPT_KEYWORDS="amd64"
ACCEPT_LICENSE="* -@EULA PUEL dlj-1.1 Oracle-BCLA-JavaSE"
CBUILD="x86_64-pc-linux-gnu"
CFLAGS="-march=core2 -O2 -pipe"
CHOST="x86_64-pc-linux-gnu"
CONFIG_PROTECT="/etc /usr/lib64/fax /usr/share/openvpn/easy-rsa /var/spool/fax/etc"
CONFIG_PROTECT_MASK="/etc/ca-certificates.conf /etc/env.d /etc/env.d/java/ /etc/fonts/fonts.conf /etc/gconf /etc/gentoo-release /etc/php/apache2-php5.3/ext-active/ /etc/php/apache2-php5.4/ext-active/ /etc/php/cgi-php5.3/ext-active/ /etc/php/cgi-php5.4/ext-active/ /etc/php/cli-php5.3/ext-active/ /etc/php/cli-php5.4/ext-active/ /etc/revdep-rebuild /etc/sandbox.d /etc/terminfo"
CXXFLAGS="-march=core2 -O2 -pipe"
DISTDIR="/usr/portage/distfiles"
FCFLAGS="-O2 -pipe"
FEATURES="assume-digests binpkg-logs collision-protect config-protect-if-modified distlocks ebuild-locks fixlafiles news parallel-fetch parse-eapi-ebuild-head protect-owned sandbox sfperms strict unknown-features-warn unmerge-logs unmerge-orphans userfetch"
FFLAGS="-O2 -pipe"
GENTOO_MIRRORS="ftp://ftp.gtlib.gatech.edu/pub/gentoo http://linux.rz.ruhr-uni-bochum.de/download/gentoo-mirror"
LANG="en_US.UTF-8"
LC_ALL="en_US.UTF-8"
LDFLAGS="-Wl,-O1 -Wl,--as-needed"
LINGUAS="en"
MAKEOPTS="-j5"
PKGDIR="/usr/portage/packages"
PORTAGE_CONFIGROOT="/"
PORTAGE_RSYNC_OPTS="--recursive --links --safe-links --perms --times --compress --force --whole-file --delete --stats --human-readable --timeout=180 --exclude=/distfiles --exclude=/local --exclude=/packages"
PORTAGE_TMPDIR="/var/tmp"
PORTDIR="/usr/portage"
PORTDIR_OVERLAY="/usr/local/portage"
SYNC="rsync://192.168.141.8/gentoo-portage"
USE="X alsa amd64 apache2 berkdb brandingdvd bzip2 cdr cgi cli consolekit cracklib crypt cups cxx dbus dri fam foomaticdb fortran gdbm gimp gimpprint gpm iconv ipv6 java jpeg lm_sensors lock mmx modules mudflap multilib mysql ncurses nls nplt nptl opengl openmp pam pcre png policykit ppds pppd readline scanner session spell sse sse2 ssl startup-notification tcpd tetex thunar tiff truetype type1 udev unicode usb zlib" ALSA_CARDS="ali5451 als4000 atiixp atiixp-modem bt87x ca0106 cmipci emu10k1x ens1370 ens1371 es1938 es1968 fm801 hda-intel intel8x0 intel8x0m maestro3 trident usb-audio via82xx via82xx-modem ymfpci" ALSA_PCM_PLUGINS="adpcm alaw asym copy dmix dshare dsnoop empty extplug file hooks iec958 ioplug ladspa lfloat linear meter mmap_emul mulaw multi null plug rate route share shm softvol" APACHE2_MODULES="actions alias auth_basic authn_alias authn_anon authn_dbm authn_default authn_file authz_dbm authz_default authz_groupfile authz_host authz_owner authz_user autoindex cache cgi cgid dav dav_fs dav_lock deflate dir disk_cache env expires ext_filter file_cache filter headers include info log_config logio mem_cache mime mime_magic negotiation rewrite setenvif speling status unique_id userdir usertrack vhost_alias" CALLIGRA_FEATURES="kexi words flow plan sheets stage tables krita karbon braindump" CAMERAS="ptp2" COLLECTD_PLUGINS="df interface irq load memory rrdtool swap syslog" ELIBC="glibc" GPSD_PROTOCOLS="ashtech aivdm earthmate evermore fv18 garmin garmintxt gpsclock itrax mtk3301 nmea ntrip navcom oceanserver oldstyle oncore rtcm104v2 rtcm104v3 sirf superstar2 timing tsip tripmate tnt ubx" INPUT_DEVICES="evdev" KERNEL="linux" LCD_DEVICES="bayrad cfontz cfontz633 glk hd44780 lb216 lcdm001 mtxorb ncurses text" LIBREOFFICE_EXTENSIONS="presenter-console presenter-minimizer" LINGUAS="en" PHP_TARGETS="php5-3" PYTHON_TARGETS="python3_2 python2_7" RUBY_TARGETS="ruby18 ruby19" SANE_BACKENDS="fujitsu" USERLAND="GNU" VIDEO_CARDS="intel vesa" XTABLES_ADDONS="quota2 psd pknock lscan length2 ipv4options ipset ipp2p iface geoip fuzzy condition tee tarpit sysrq steal rawnat logmark ipmark dhcpmac delude chaos account"
Unset:  CPPFLAGS, CTARGET, EMERGE_DEFAULT_OPTS, INSTALL_MASK, PORTAGE_BUNZIP2_COMMAND, PORTAGE_COMPRESS, PORTAGE_COMPRESS_FLAGS, PORTAGE_RSYNC_EXTRA_OPTS, USE_PYTHON
Comment 3 Joseph 2012-11-25 17:43:27 UTC
I've asked the same question on Asterisk-user forum hoping to solve this problem and there is what somebody suggesed: 

------quote-----------
        ebegin "Stopping asterisk PBX gracefully"
        /usr/sbin/asterisk -r -x "core stop gracefully" &>/dev/null
        # Now we have to wait until asterisk has _really_ stopped.


   As you can see, it is trying to execute "core stop gracefully". I don't
   know why it wont shutdown, or maybe it would but you can't wait till it
   happens, so I can't help in troubleshooting.

   But if you need a quick workaround to be able to shut down without
   killing process - change it to "core stop now". It should shut the
   Asterisk down immediately, dropping all active calls.
------end quote--------
Comment 4 Tony Vroon gentoo-dev 2012-11-25 20:10:38 UTC
(In reply to comment #3)
>    But if you need a quick workaround to be able to shut down without
>    killing process - change it to "core stop now". It should shut the
>    Asterisk down immediately, dropping all active calls.

I trust you're not suggesting we add this to the production ebuild. These phone systems are used in environments where terminated calls result in loss of productivity and perhaps even reputation.
What you need to find out is why your Asterisk gets stuck. Also, please try 1.8.18.0-r1 which is the new 1.8 stable candidate. A considerable amount of bugfixes has gone in since 1.8.15.1 and one of them may well have addressed this.
Comment 5 Joseph 2012-11-25 21:21:40 UTC
> I trust you're not suggesting we add this to the production ebuild. These
> phone systems are used in environments where terminated calls result in loss
> of productivity and perhaps even reputation.
> What you need to find out is why your Asterisk gets stuck. Also, please try
> 1.8.18.0-r1 which is the new 1.8 stable candidate. A considerable amount of
> bugfixes has gone in since 1.8.15.1 and one of them may well have addressed
> this.

No, that wouldn't be the correct solution. On a small network office, this solution would be OK for me but not larger network with many users.

I don't know how to test/troubleshoot why the Asterisk gets stuck.  
It only hapens when asterisk has been running for few days or so. 
So I don't know what command to use and what to test for. 

Asterisk-1.8.18.0-r1 is still mark unstable, but I'll install it soon.
Comment 6 Jaco Kroon 2012-11-26 07:25:09 UTC
Hi,

Just to clarify and add my 5c worth.

core stop gracefully is usually the correct solution, if it won't shut down it's probably a configuration issue, or potentially a stuck call (use core show channels concise to figure out which channel and hangup request to hang it up).  It will also stop asterisk from accepting new calls - which may not be what some people want (at least not on a restart, on a shutdown you don't want new calls).

core stop now will drop all calls immediately, which is obviously not what we want.

core stop when convenient will not prevent new calls, and will wait for a period of inactivity to stop.

Tony - we may want to make which of the three options we use configurable?  I should be able to do that for you quite easily - defaulting to graceful.

Then, also, it may be beneficial to have an explicit restart that issues "core restart {now|gracefull|when convenient}" as well ... but I don't see any real sense to this if the above is done.  I typically issue 'asterisk -rx "core restart when convenient"' as root from the shell if I need a restart anyway, then sit in another asterisk CLI waiting for the restart to happen ... can sometimes be hours on some of our servers (in which case I just do watch 'asterisk -rnx "core show uptime"' and wait for the value to go smaller. (usually I just do this after 22:00 unless it's particularly urgent and then I'll use gracefully anyway, just take the reputation wrap and be done with it).
Comment 7 Joseph 2012-11-26 14:57:31 UTC
Thank you for the input Jaco; that is very informative.
I'll keep an eye on my asterisk servers and report any finding in few days.
Comment 8 Joseph 2012-12-08 05:10:51 UTC
I know why is it doing it.  I just run:

asterisk -rx "core show channels"
Channel              Location             State   Application(Data)             
SIP/pstn-9998-000000 (None)               Up      AppDial((Outgoing Line))      
SIP/pstn-4444-000000 7807080993@internal: Up      Dial(SIP/77807080993@pstn-9998
2 active channels
1 active call
62 calls processed

so my fax line appears UP (pstn-9998) and I don't know why.
I called my fax line externally and it answers the call.

How do I hang up the channel from command line?
Comment 9 Jaco Kroon 2012-12-09 15:37:15 UTC
(In reply to comment #8)
> I know why is it doing it.  I just run:
> 
> asterisk -rx "core show channels"
> Channel              Location             State   Application(Data)         
> 
> SIP/pstn-9998-000000 (None)               Up      AppDial((Outgoing Line))  
> 
> How do I hang up the channel from command line?

hangup request SIP/pstn-9998-000000
Comment 10 Joseph 2012-12-11 02:47:02 UTC
I got the same situation today, it keeps showing one line is active even though nobody is using it.

asterisk -rx "core show channels"
Channel              Location             State   Application(Data)             
SIP/pstn-4444-000000 (None)               Up      AppDial((Outgoing Line))      
SIP/pstn-9998-000000 7807586576@internal: Up      Dial(SIP/97807807586576@pstn-4
2 active channels
1 active call
77 calls processed

How can I monitor it or prevent it?
Comment 11 Tony Vroon gentoo-dev 2012-12-11 10:24:55 UTC
Sounds like you need disconnect supervision on your analog line.
Comment 12 Tony Vroon gentoo-dev 2013-01-30 11:12:33 UTC
I believe this to be a lack of disconnect supervision on an analog telephone line. This is a configuration change that will need to be made on your end.
Comment 13 Joseph 2013-01-30 16:51:08 UTC
I'm not so sure this is related to disconnect supervision at all.
What I have noticed that it only happens when aseriks made about 230+ call.
If I restart asterisk before or every second or third day it is not occuring at all.