Binding shell script when Asterisk restarting itself

Hi Folks,

I’m using asterisk/node-ari-client as the library for connecting with Asterisk’s ARI. It is working fine until the Asterisk restart itself (with several reasons such as RTP ports are not enough). In this case, I need to manually restart my Node.JS application so that the new call will be answered again.

Is there any binding point in Asterisk to blind a startup shell script so that I can run the restart command to restart my Node.JS application while Asterisk is restarting.

Thanks for any advice
Tanakom.

Asterisk doesn’t restart itself, after a crash. It is normally restarted by a script called safe asterisk.

https://linux.die.net/man/8/safe_asterisk

1 Like

Just wrap your node script in a while true loop . You can add some try catch inside of it and in the catch maybe do a sleep for one second time for asterisk restart.
On the second hand asterisk should never have to crash … so you probably doing something seriousely wrong in the config files.

1 Like