Ejabberd与Emysql集成
开发模块需要使用到MySQL数据库,本文描述如何把Emysql
集成到Ejabberd中.
修改Ejabberd
编辑$EJABBERD_SRC/rebar.config.script
配置Deps
,增加Emysql
依赖
1 | Deps = [ ... {emysql, ".*", {git, "git://github.com/Eonblast/Emysql.git"}} ], |
如果已经编译过了ejabberd,请删除deps/.built
, deps/.got
两个文件, 并执行make
1 | root@fd4cc081e295:~/ejabberd# make ... ==> emysql (compile) Generating "include/crypto_compat.hrl" ... ...supports cryto:hash/2 ...writing "include/crypto_compat.hrl" Compiled src/emysql.erl Compiled src/emysql_worker.erl Compiled src/emysql_conn_mgr.erl Compiled src/emysql_sup.erl Compiled src/emysql_util.erl Compiled src/emysql_conn.erl Compiled src/emysql_app.erl Compiled src/emysql_statements.erl Compiled src/emysql_auth.erl Compiled src/emysql_conv.erl Compiled src/emysql_tcp.erl ==> p1_mysql (compile) ==> p1_zlib (compile) ==> jiffy (compile) ==> goldrush (compile) ==> lager (compile) ==> p1_iconv (compile) ==> rel (compile) ==> ejabberd (compile) Compiled src/mod_gbox_messager.erl Compiled src/mod_online_users.erl Compiled src/mod_cputime.erl Compiled src/mod_system_information.erl /usr/lib/erlang/bin/escript rebar skip_deps=true compile ==> rel (compile) ==> ejabberd (compile) |
下载安装samples数据库
1 | wget https://launchpad.net/test-db/employees-db-1/1.0.6/+download/employees_db-full-1.0.6.tar.bz2 tar jxf employees_db-full-1.0.6.tar.bz2 cd employees_db mysql -t < employees.sql |
修改模块
1 | -module(mod_cputime). |
查询结果日志输出