Restart asterisk when there is this error

Hi
I’d like to write a procedure that when asterisk show this warning: " WARNING[3717]" it restart itself gracefuly.
It is possible and in which way?

Can you help me.

Thanks
Antonio