Asterisk won't restart?

I was working on a system last night and noticed that when I checked the status of Asterisk it would provide an odd bad, disabled message. I tried to restart it but it just hung. Eventually I ran an asterisk-version-switch which brought it back to life but even after that when I run the asterisk status I’m not seeing the normal Running page. Any thoughts?

 service asterisk status
● asterisk.service - LSB: Asterisk PBX
   Loaded: loaded (/etc/rc.d/init.d/asterisk; bad; vendor preset: disabled)
   Active: active (running) since Fri 2019-05-24 22:01:50 CDT; 5 days ago
     Docs: man:systemd-sysv-generator(8)
 Main PID: 22806
   CGroup: /system.slice/asterisk.service

May 24 22:01:50 tower.cqsimple.org systemd[1]: Starting LSB: Asterisk PBX...
May 24 22:01:50 tower.cqsimple.org asterisk[23750]: Asterisk is already running.
May 24 22:01:50 tower.cqsimple.org systemd[1]: asterisk.service: Supervising....
May 24 22:01:50 tower.cqsimple.org systemd[1]: Started LSB: Asterisk PBX.
Hint: Some lines were ellipsized, use -l to show in full.
[root@tower ~]# service asterisk restart
Restarting asterisk (via systemctl):  ^C
[root@tower ~]# service asterisk start
Starting asterisk (via systemctl):  ^C
[root@tower ~]# service asterisk status
● asterisk.service - LSB: Asterisk PBX
   Loaded: loaded (/etc/rc.d/init.d/asterisk; bad; vendor preset: disabled)
   Active: deactivating (stop-sigterm) since Thu 2019-05-30 21:45:59 CDT; 3min 1                                                                                                                                                             3s ago
     Docs: man:systemd-sysv-generator(8)
  Process: 18063 ExecStop=/etc/rc.d/init.d/asterisk stop (code=exited, status=0/                                                                                                                                                             SUCCESS)
 Main PID: 22806
   CGroup: /system.slice/asterisk.service


service asterisk status
● asterisk.service - LSB: Asterisk PBX
   Loaded: loaded (/etc/rc.d/init.d/asterisk; bad; vendor preset: disabled)
   Active: deactivating (final-sigkill) (Result: timeout) since Thu 2019-05-30 21:45:59 CDT; 16min ago
     Docs: man:systemd-sysv-generator(8)
 Main PID: 22806
   CGroup: /system.slice/asterisk.service

May 24 22:01:50 tower.cqsimple.org systemd[1]: Starting LSB: Asterisk PBX...
May 24 22:01:50 tower.cqsimple.org asterisk[23750]: Asterisk is already running.
May 24 22:01:50 tower.cqsimple.org systemd[1]: asterisk.service: Supervising process 22806 which is not our child. We'll most likely not notice when it exits.
May 24 22:01:50 tower.cqsimple.org systemd[1]: Started LSB: Asterisk PBX.
May 30 21:45:59 tower.cqsimple.org systemd[1]: Stopping LSB: Asterisk PBX...
May 30 21:45:59 tower.cqsimple.org asterisk[18063]: Stopping safe_asterisk: [  OK  ]
May 30 21:45:59 tower.cqsimple.org asterisk[18063]: Shutting down asterisk: [  OK  ]
May 30 21:50:59 tower.cqsimple.org systemd[1]: asterisk.service stop-sigterm timed out. Killing.
May 30 21:55:59 tower.cqsimple.org systemd[1]: asterisk.service still around after SIGKILL. Ignoring.
May 30 22:01:00 tower.cqsimple.org systemd[1]: asterisk.service stop-final-sigterm timed out. Killing.

Checking just now I see the following (although asterisk does appear to be running on the system?)

service asterisk status
● asterisk.service - LSB: Asterisk PBX
   Loaded: loaded (/etc/rc.d/init.d/asterisk; bad; vendor preset: disabled)
   Active: failed (Result: resources) since Thu 2019-05-30 22:06:59 CDT; 9h ago
     Docs: man:systemd-sysv-generator(8)
  Process: 6480 ExecStart=/etc/rc.d/init.d/asterisk start (code=exited, status=0/SUCCESS)
 Main PID: 22806

May 30 22:06:59 tower.cqsimple.org systemd[1]: Starting LSB: Asterisk PBX...
May 30 22:06:59 tower.cqsimple.org asterisk[6480]: Asterisk is already running.
May 30 22:06:59 tower.cqsimple.org systemd[1]: PID file /var/run/asterisk/asterisk.pid not readable (yet?) after start.
May 30 22:06:59 tower.cqsimple.org systemd[1]: Failed to start LSB: Asterisk PBX.
May 30 22:06:59 tower.cqsimple.org systemd[1]: Unit asterisk.service entered failed state.
May 30 22:06:59 tower.cqsimple.org systemd[1]: asterisk.service failed.

I believe you are seeing that because on FreePBX Distro, Asterisk is not meant to be started with systemctl, but it will be started with fwconsole commands.

Just to show you my FreePBX Distro SNG7 output, even though Asterisk is running, systemctl is showing it as stopped.

[root@freepbx ~]# service asterisk status
● asterisk.service - LSB: Asterisk PBX
Loaded: loaded (/etc/rc.d/init.d/asterisk; bad; vendor preset: disabled)
Active: inactive (dead)
Docs: man:systemd-sysv-generator(8)

[root@freepbx ~]# ps -ef|grep safe_asterisk
root 15083 1 0 May26 ? 00:00:00 /bin/sh /usr/sbin/safe_asterisk -U asterisk -G asterisk

[root@freepbx ~]# ps -ef|grep 15083
root 15083 1 0 May26 ? 00:00:00 /bin/sh /usr/sbin/safe_asterisk -U asterisk -G asterisk
asterisk 15089 15083 0 May26 ? 00:34:37 /usr/sbin/asterisk -f -U asterisk -G asterisk -vvvg -c

1 Like

Probably a stupid question - How can I check the status of Asterisk either from the general command line or from the asterisk cli?

Not stupid, you are not supposed to know everything, don’t worry :wink:

I’m not aware of a specific fwconsole command to check for Asterisk status, but since on FreePBX Distro Asterisk is supposed to be started by safe_asterisk, you can do a pf -es|grep safe_asterisk and then pf -ef|grep NUMBER_OF_PID_FROM_COMMAND_BEFORE just like I showed you on my previous reply

1 Like

As @arielgrin said, you only ever start Asterisk using fwconsole using:

fwconsole start|stop|restart

Running asterisk -r at the bash prompt will put you in the asterisk console which will tell you it’s running.

1 Like

Did running service asterisk status and service asterisk restart used to be an acceptable practice? I feel like I’ve used it prior successfully. Thank you for the insight on best practices, greatly appreciated

Not if I can remember on previous versions, but on SNG7 for sure not.

Prior to SNG7, you could get useful output from service asterisk status, but it has never been acceptable to start asterisk with anything other than fwconsole (or amportal back before ver. 13).

1 Like

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.