tsung启动使用到了erlang的application中的start_phases方法。
在tsung的启动脚本中:
$ERL $ERL_OPTS $ERL_RSH -noshell $PROTO_DIST $NAMETYPE $CONTROLLER -setcookie $COOKIE \ -s tsung_controller \ $EXTRA_LOAD_PATHS \
可以知道,tsung使用了tsung_controller模块中的start函数启动的。
然后在tsung_controller.app文件中有定义:
{start_phases, [{load_config, []},{start_os_monitoring,[{timeout,30000}]}, {start_clients,[]}]}, {mod, {tsung_controller, []}}
这个跟tsung启动脚步对应,tsung_controller模块启动tsung_controller应用,然后启动load_config, start_os_monitoring, start_clients阶段。
在app模块中,有说明:
start_phases A list of start phases and corresponding start arguments for the application. If this key is present, the application master will - in addition to the usual call to Module:start/2 - also callModule:start_phase(Phase,Type,PhaseArgs) for each start phase defined by the start_phases key, and only after this extended start procedure will application:start(Application) return.
然后看到tsung_controller.erl模块中有:
start_phase(load_config, _StartType, _PhaseArgs) -》 start_phase(start_os_monitoring, _StartType, _PhaseArgs) -> start_phase(start_clients, _StartType, _PhaseArgs) ->
然后在start_clients阶段中,启动了tsung应用。
tsung应用中负责产生负载测试。