window下搭建cowboy_app

来源:互联网 发布:通路分销 源码 编辑:程序博客网 时间:2024/05/24 15:38
1.下载cowboy-master.zip,cowlib-master.zip,ranch-master.zip
2.很简单在window上很难使用erlang管理工具,最简单最源次的做法就是把所有的.erl都放到一个ebin目录下面,新建一个ebin目录,编译将所有的.beam放到下面
3.写一个Emakefile来自动编译
{
[
'cowboy-master/src/*',
'cowlib-master/src/*',
'ranch-master/src/*',
'src/*'
]
,[
debug_info
,{i, "cowlib-master/include"}
,{outdir, "ebin"}
]
}.


erl -make
4.这时候发现错误can  not find include lib "cowlib/include/cow_inline.hrl" ...
找到这个文件cowboy_http.erl
-include_lib("cowlib/include/cow_inline.hrl").
     -include_lib("cowlib/include/cow_parse.hrl").
     改成:
    -include("cow_inline.hrl").
    -include("cow_parse.hrl").
    5.复制cowboy.app,cowlib.app,ranch.app 到ebin目录
    6.编写自己的app,用cowboy里面的Hello_world
      (1).编写一个Hello_world.app文件用来启动
      {application, hello_world, [
{description, "hello_world http test"},
{vsn, "1.0"},
{modules, [hello_world_app,hello_world_sup,toppage_handler]},
{registered, [hello_world_sup]},
{applications, [kernel,stdlib]},
{mod, {hello_world_app, []}}
]}.
(2).修改hello_world_app.erl在start加入先启动库
ok = application:start(crypto),
ok = application:start(cowlib),
ok = application:start(ranch),
ok = application:start(cowboy),
0 0