《FreeSWITCH参考手册》

1.8 mod_commands

接下来,我们来看一下mod_commands模块。该模块实现了系统大多数的API命令,如versionstatus以及我们常用的originate等。

类似于上一节,我们可以通过reload模块的方式查看模块的一些信息,不妨输入下列命令试试:

freeswitch> reload`mod_commands`

+OK Reloading XML

-ERR unloading module [Module is not unloadable]

我们看到,该命令无情地抛出了一个错误,说该模块是无法被卸载的,自然,就无法重新加载了。看来,我们昨天学到的技术不好用了。我们只得另想办法。

我们知道fs_cli可以做为一个客户端连接到FreeSWITCH上,看日志,执行命令什么的。其实,它也有一个小的技巧,就是,用-x参数执行一个命令立即即出,如:

$ fs_cli -x "status"

UP 0 years, 0 days, 13 hours, 46 minutes, 47 seconds, 330 milliseconds, 78 microseconds
FreeSWITCH (Version 1.5.8b git 0c8d8ba 2014-01-16 01:06:11Z 64bit) is ready
6 session(s) since startup
0 session(s) - peak 1, last 5min 0
0 session(s) per Sec out of max 200, peak 1, last 5min 0
3000 session(s) max
min idle cpu 0.00/100.00
Current Stack Size/Max 240K/8192K

哇,既然能这样用就好办了。我们可以用下面的命令看一看mod_commands模块中都实现了哪些API命令:

$ fs_cli -x "help" | grep`mod_commands`
...,,Shutdown`mod_commands`
acl,<ip> <list_name>,Compare an ip to an acl list`mod_commands`
alias,[add|stickyadd] <alias> <command> | del [<alias>|*],Alias`mod_commands`
banner,,Return the system banner`mod_commands`
bg_system,<command>,Execute a system command in the background`mod_commands`
bgapi,<command>[ <arg>],Execute an api command in a thread`mod_commands`
… 此处省略XXXX字

其实,这里的help命令也是在mod_commands里实现的,同样,load/unload/reload也都是,这也是为什么该模块不能卸载的根本原因——unload依赖mod_commands,所以,它不能卸载自己所在的模块。

当然,另外一个方法就是到Wiki上找文档了。该模块的文档还是挺全的。见:https://freeswitch.org/confluence/display/FREESWITCH`mod_commands`

通过这两节你应该会注意到一些小技巧:如通过reload一个模块查看某模块中实现了哪些Interface这种技巧。如果想好好学习的话一定要注意发现。以后,我们就不详细详解这些技巧的细节了。



本书版权所有 © 杜金房及各位贡献者 2016-2023,仅供在线阅读,谢绝一切形式转载。 本书还在写作中,持续更新。 如果你也想写上几句,欢迎加入我们。 | 返回首页 |