OpenSIPs Dev Tips: check opensips config syntax on Mac or Windows using docker
If you develop with opensips on Mac or Windows, frustration will quickly set in when you think you have your opensips.cfg
file ready for testing calls, so you push to your remote server or VM, try to start opensips, and get an error like this:
Jun 7 16:15:36 [1] Traceback (last included file at the bottom):
Jun 7 16:15:36 [1] 0. /etc/opensips/opensips.cfg
Jun 7 16:15:36 [1] CRITICAL:core:yyerror: parse error in /etc/opensips/opensips.cfg:9:1-9: syntax error
The feedback loop is just too slow.
I don't want to have to push to a remote server, VM, or container, and then get a shall, and start opensips just to find out I made a silly mistake in syntax.
Make sure you have your opensips.cfg
file in your current directory.
Use the below command to quickly check your config syntax:
docker run -v ${PWD}/:/etc/opensips --entrypoint /usr/sbin/opensips opensips/opensips:latest -C -f /etc/opensips/opensips.cfg
Now you can fix your syntax before pushing to a remote server to test calls.