Menu

How do I delay asterisk starting after rebooting until the Lan is up?

Dennis H
2017-08-12
2017-08-12
  • Dennis H

    Dennis H - 2017-08-12

    Whenever I reboot my Pi, asterisk restarts without waiting for the Lan to come up. The result is that nothing connects and it doesn't make any attempt to reconnect once the lan is up. I can fix this manually by running "CORE RELOAD" from the asterisk CLI. Then everything reconnects properly.

    I have been reading around the web and some say that the problem may be in the /etc/init.d/asterisk file, but after looking at that file, I have determined that I don't know enough about it to mess with it.

    Is init.d the correct place to fix this problem or is there another place inside asterisk that will make it wait for the lan before freaking out? What should I change to make this work properly?

    Thanks.

     
  • Gernot

    Gernot - 2017-09-02

    Asterisk is started through systemd using the file /etc/systemd/system/freepbx.service. You could try to add

    After=network-online.target
    

    to the Unit section of this file, causing Asterisk to wait for network service before starting. If this does not help, a simple pause could be introduced by adding

    ExecStartPre=/bin/sleep 30
    

    to the Service section.

     
  • Dennis H

    Dennis H - 2017-09-02

    Thanks for the reply. I'm using plain asterisk and not freepbx, so there is no "freepbx.service" file. However, I think this is the right direction.

    I think the problem is in the /etc/init.d/asterisk file. I just can't make sense of it.

    This is definitely something that needs fixing because I was away for a while and because of a power failure, it came back up in a non-working state. The raspberry itself was fine. When I got back, I just ran "core reload" from the CLI - again- and all was well.

    Honestly I think that this is an asterisk bug because network connectivity can go up and down all the time and asterisk shouldn't freak out like that.

     

Log in to post a comment.