Asterisk wont auto start

CentOS 7
Asterisk 13.18.2

Once Installed I ran the following
sudo make config

chkconfig
asterisk 0:off 1:off 2:on 3:on 4:on 5:on 6:office:

Once I restart
ps aux | grep asterisk
root 1101 0.0 0.0 115256 936 ? S 02:25 0:00 /bin/sh /usr/sbin/safe_asterisk

it appears to be running but when I run the following command
sudo asterisk -rvvv
Unable to connect to remote asterisk (does /var/run/asterisk/asterisk.ctl exist?)

when I do run the following command it works
sudo asterisk
then I can sudo asterisk -rvvv

But I want it to run automatically when I reboot

safe_asterisk is script that starts asterisk and restarts it if terminates abnormally. Look at the logs or run asterisk -cvvv and see what happens.

When I run asterisk -cvvv it runs fine
but what I want is it to start asterisk automatically
so when I run asterisk -rvvv it works

currently when I reboot and run asterisk -rvvv it says
Unable to connect to remote asterisk (does /var/run/asterisk/asterisk.ctl exist?)

maybe im not understanding something

So what do the logs say?

where can I get the log from?
you mean the output from asterisk -cvvv?

For a default installation, /var/log/asterisk/*

/var/log/asterisk/messages

[Nov 19 05:00:05] Asterisk 13.18.2 built by root @ localhost.localdomain on a x86_64 running Linux on 2017-11-19 09:55:37 UTC
[Nov 19 05:00:05] NOTICE[1491] cdr.c: CDR simple logging enabled.
[Nov 19 05:00:05] NOTICE[1491] loader.c: 305 modules will be loaded.
[Nov 19 05:00:05] NOTICE[1491] res_odbc.c: res_odbc loaded.
[Nov 19 05:00:05] WARNING[1491] res_phoneprov.c: Unable to find a valid server address or name.
[Nov 19 05:00:05] ERROR[1491] ari/config.c: No configured users for ARI
[Nov 19 05:00:05] NOTICE[1491] pbx_lua.c: Lua PBX Switch loaded.
[Nov 19 05:00:05] NOTICE[1491] res_config_ldap.c: No directory user found, anonymous binding as default.
[Nov 19 05:00:05] ERROR[1491] res_config_ldap.c: No directory URL or host found.
[Nov 19 05:00:05] ERROR[1491] res_config_ldap.c: Cannot load LDAP RealTime driver.
[Nov 19 05:00:05] ERROR[1491] res_config_pgsql.c: PostgreSQL RealTime: Failed to connect database asterisk on 127.0.0.1:
[Nov 19 05:00:05] WARNING[1491] res_config_pgsql.c: PostgreSQL RealTime: Couldn't establish connection. Check debug.
[Nov 19 05:00:05] NOTICE[1491] chan_skinny.c: Configuring skinny from skinny.conf
[Nov 19 05:00:05] NOTICE[1491] confbridge/conf_config_parser.c: Adding default_menu menu to app_confbridge
[Nov 19 05:00:05] NOTICE[1491] cdr_pgsql.c: cdr_pgsql configuration contains no global section, skipping module load.
[Nov 19 05:00:05] NOTICE[1491] cel_custom.c: No mappings found in cel_custom.conf. Not logging CEL to custom CSVs.
[Nov 19 05:00:05] WARNING[1491] cel_pgsql.c: CEL pgsql config file missing global section.
[Nov 19 05:04:59] Asterisk 13.18.2 built by root @ localhost.localdomain on a x86_64 running Linux on 2017-11-19 09:55:37 UTC
[Nov 19 05:04:59] NOTICE[11796] cdr.c: CDR simple logging enabled.
[Nov 19 05:04:59] NOTICE[11796] loader.c: 305 modules will be loaded.
[Nov 19 05:04:59] NOTICE[11796] res_odbc.c: res_odbc loaded.
[Nov 19 05:04:59] WARNING[11796] res_phoneprov.c: Unable to find a valid server address or name.
[Nov 19 05:04:59] ERROR[11796] ari/config.c: No configured users for ARI
[Nov 19 05:04:59] NOTICE[11796] pbx_lua.c: Lua PBX Switch loaded.
[Nov 19 05:05:00] NOTICE[11796] res_config_ldap.c: No directory user found, anonymous binding as default.
[Nov 19 05:05:00] ERROR[11796] res_config_ldap.c: No directory URL or host found.
[Nov 19 05:05:00] ERROR[11796] res_config_ldap.c: Cannot load LDAP RealTime driver.
[Nov 19 05:05:00] ERROR[11796] res_config_pgsql.c: PostgreSQL RealTime: Failed to connect database asterisk on 127.0.0.1:
[Nov 19 05:05:00] WARNING[11796] res_config_pgsql.c: PostgreSQL RealTime: Couldn't establish connection. Check debug.
[Nov 19 05:05:00] NOTICE[11796] chan_skinny.c: Configuring skinny from skinny.conf
[Nov 19 05:05:00] NOTICE[11796] confbridge/conf_config_parser.c: Adding default_menu menu to app_confbridge
[Nov 19 05:05:00] NOTICE[11796] cdr_pgsql.c: cdr_pgsql configuration contains no global section, skipping module load.
[Nov 19 05:05:00] NOTICE[11796] cel_custom.c: No mappings found in cel_custom.conf. Not logging CEL to custom CSVs.
[Nov 19 05:05:00] WARNING[11796] cel_pgsql.c: CEL pgsql config file missing global section.
[Nov 19 05:05:11] Asterisk 13.18.2 built by root @ localhost.localdomain on a x86_64 running Linux on 2017-11-19 09:55:37 UTC
[Nov 19 05:05:11] NOTICE[11895] cdr.c: CDR simple logging enabled.
[Nov 19 05:05:11] NOTICE[11895] loader.c: 305 modules will be loaded.
[Nov 19 05:05:12] NOTICE[11895] res_odbc.c: res_odbc loaded.
[Nov 19 05:05:12] WARNING[11895] res_phoneprov.c: Unable to find a valid server address or name.
[Nov 19 05:05:12] ERROR[11895] ari/config.c: No configured users for ARI
[Nov 19 05:05:12] NOTICE[11895] pbx_lua.c: Lua PBX Switch loaded.
[Nov 19 05:05:12] NOTICE[11895] res_config_ldap.c: No directory user found, anonymous binding as default.
[Nov 19 05:05:12] ERROR[11895] res_config_ldap.c: No directory URL or host found.
[Nov 19 05:05:12] ERROR[11895] res_config_ldap.c: Cannot load LDAP RealTime driver.
[Nov 19 05:05:12] ERROR[11895] res_config_pgsql.c: PostgreSQL RealTime: Failed to connect database asterisk on 127.0.0.1:
[Nov 19 05:05:12] WARNING[11895] res_config_pgsql.c: PostgreSQL RealTime: Couldn't establish connection. Check debug.
[Nov 19 05:05:12] NOTICE[11895] chan_skinny.c: Configuring skinny from skinny.conf
[Nov 19 05:05:12] NOTICE[11895] confbridge/conf_config_parser.c: Adding default_menu menu to app_confbridge
[Nov 19 05:05:12] NOTICE[11895] cdr_pgsql.c: cdr_pgsql configuration contains no global section, skipping module load.
[Nov 19 05:05:12] NOTICE[11895] cel_custom.c: No mappings found in cel_custom.conf. Not logging CEL to custom CSVs.
[Nov 19 05:05:12] WARNING[11895] cel_pgsql.c: CEL pgsql config file missing global section.
[Nov 19 05:05:24] Asterisk 13.18.2 built by root @ localhost.localdomain on a x86_64 running Linux on 2017-11-19 09:55:37 UTC
[Nov 19 05:05:24] NOTICE[11926] sorcery.c: Type 'system' is not reloadable, maintaining previous values
[Nov 19 05:05:24] WARNING[11895] res_phoneprov.c: Unable to find a valid server address or name.
[Nov 19 05:05:24] ERROR[11895] ari/config.c: No configured users for ARI
[Nov 19 05:05:24] NOTICE[11895] pbx_lua.c: Lua PBX Switch loaded.
[Nov 19 05:05:24] NOTICE[11895] res_config_ldap.c: No directory user found, anonymous binding as default.
[Nov 19 05:05:24] ERROR[11895] res_config_ldap.c: No directory URL or host found.
[Nov 19 05:05:24] NOTICE[11895] res_config_ldap.c: Cannot reload LDAP RealTime driver.
[Nov 19 05:05:24] NOTICE[11895] chan_skinny.c: Configuring skinny from skinny.conf
[Nov 19 05:05:24] NOTICE[11895] cel_custom.c: No mappings found in cel_custom.conf. Not logging CEL to custom CSVs.
[Nov 19 05:05:24] NOTICE[11895] app_queue.c: queuerules.conf has not changed since it was last loaded. Not taking any action.


So this is a brand new fresh install of the new asterisk 13.18.2
I didnt edit anything yet, I was wondering why it doesnt automatically start on boot

Do i need to have everything setup then it automatically start?

You don’t need anything special.

If you are sure the log came from an automated start, the next step is to obtain a backtrace (google “asterisk wiki backtrace”).

Are you running on a VM, as some VMs mis-declare their hardware capabilities such that the compiler compiles instructions that the machine can neither execute not emulate. However, I’d expect that to show on asterisk -c, as well.

Yes I’m running this on HyperV which asterisk reside in an VM
When I run sudo asterisk -cvvv, it doesnt output any major issue beside couple warnings regarding pgsql
I just dont understand why it doesnt start automatically
Last time I installed asterisk 13.17.1, it started fine with the same setup

If the log comes from an automated start, it has started automatically, and then crashed, which is why you need the backtrace.

The other likely problem would be a permissions problem.

I ran couple test.
I check my log and last time was 6:25
I restart the VM at 6:35 and log wasnt updated…


I went to my OLD VM Asterisk 13.17.1 which start on boot
and check command “service asterisk status”
I notice the following highlight is not running on my new build


My current Asterisk 13.18.2 doesnt have the following running
/usr/sbin/asterisk -f -vvvg -c
it appears to be going to sleep ??

if safe_asterisk is running, the OS side of the start-up was successful. If safe_asterisk is continually trying to start asterisk it will be because of a crash or a permissions problem.

Assuming that safe_asterisk hasn’t changed much in a long time, the only place it does sleep 4 is in the go around after Asterisk exits with a non-normal status (which includes failure to launch the executable at all).

			nice -n $PRIORITY ${ASTSBINDIR}/asterisk -f ${CLIARGS} ${ASTARGS} > /dev/${TTY} 2>&1 < /dev/${TTY}
.....
		EXITSTATUS=$?
		message "Asterisk ended with exit status $EXITSTATUS"
		if [ "$EXITSTATUS" = "0" ]; then
....
                fi
		message "Automatically restarting Asterisk."
		sleep $SLEEPSECS

(Some details, including logging, removed, for clarity.)

message writes to standard error, whatever that is in the boot up environment. You can uncomment lines in safe_asterisk to have it sent to a file and/or syslog.

1 Like

When I disable SELINUX=disabled
I’m using CentOS 7
It Works, the question is WHY?

https://access.redhat.com/documentation/en-us/red_hat_enterprise_linux/6/html/security-enhanced_linux/sect-security-enhanced_linux-enabling_and_disabling_selinux-disabling_selinux

Disable Selinux while installing Asterisk then asfter done enabel it and everything works fine