-
获取:
dev@debian:~/Work/ShankYan$ git clone git://github.com/esl/ecron.git
-
编译:
dev@debian:~/Work/ShankYan/ecron$ rebar com ==> ecron (compile) Dependency not available: meck-.* ({git,"git://github.com/esl/meck.git", "HEAD"}) Dependency not available: edown-.* ({git,"git://github.com/esl/edown.git", "HEAD"}) ERROR: compile failed while processing /home/dev/Work/ShankYan/ecron: rebar_abort
解决(rebar get-deps com )或者在ecron下创建deps文件夹,然后进入deps文件夹,
git clone git://github.com/esl/meck.git git clone git://github.com/esl/edown.git dev@debian:~/Work/ShankYan/ecron$ rebar com ok
-
测试代码:
在ecron.app文件中修改为
{env, [ {scheduled, [ {{{ '*', '*', '*'}, {14, 50, 0}}, {mytest, test, [2, 4]}}, {{{ '*', '*', '*'}, {14, 49, 0}}, {mytest, test, [2, 4]}}, {{{ '*', '*', '*'}, {14, 48, 0}}, {mytest, test, [2, 4]}}, {{{ '*', '*', '*'}, {14, 47, 0}}, {mytest, test, [2, 4]}}, {{{ '*', '*', '*'}, {14, 46, 0}}, {mytest, test, [2, 4]}}, {{{ '*', '*', '*'}, {14, 45, 0}}, {mytest, test, [2, 4]}}, {{{ '*', '*', '*'}, {14, 44, 0}}, {settlement_ecron, apply, []}} %{{{ '*', '*', '*'}, {16, 20, 0}}, {settlement_ecron, sys_init, []}} % {{{ '*', '*', '*'}, {15, 40, 0}}, {settlement_ecron, migrate, []}} % {{{ '*', '*', '*'}, {15, 40, 0}}, {settlement_ecron, finalize, []}} ]}, {event_handlers,[{ecron_event, []}]}]}
在src中添加
-module(mytest). -export([test/2]). test(X, Y) -> io:format("I'm come for ecron test...~n"), {ok, X+Y}. <
并重新编译
-
运行 当然
%% >mnesia:create_schema([node()]). %% >mnesia:start(). %% >ecron:install(). 是上面说的用法 handle收到消息的操作就是直接输出,结果如下所示: dev@debian:~/Work/ShankYan/ecron$ erl -pa ./ebin -name d@example4.com Erlang R16B03-1 (erts-5.10.4) [source] [64-bit] [smp:2:2] [async-threads:10] [kernel-poll:false] Eshell V5.10.4 (abort with ^G) (d@example4.com)1> mnesia:start(). ok (d@example4.com)2> ecron:install(). ok (d@example4.com)3> application:start(ecron). ok (d@example4.com)4> I'm come for ecron test... ***Executed {{{' *','*','*'},{14,49,0}},{mytest,test,[2,4]}} at {{2014,9,3},{14,49,0}} expected at {{2014,9,3},{14,49,0}} Result = {ok, 6} (d@example4.com)4> I'm come for ecron test... ***Executed {{{'*','*','*'},{14,50,0}},{mytest,test,[2,4]}} at {{2014,9,3},{14,50,0}} expected at {{2014,9,3},{14,50,0}} Result = {ok, 6} (d@example4.com)4> (d@example4.com)4>
-
最后
***Executed {{{'*','*','*'},{15,11,0}},{mytest,test,[2,4]}} at {{2014,9,3},{15,11,0}} expected at {{2014,9,3},{15,11,0}} Result = {ok, 6}