接:erlang:基于cowboy,一键创建erlang工程(一)
mk_runScript(){
goProjectPath
echo "#!/bin/bash" >>$runScript
echo "# this is erlang template runScript!!">>$runScript
echo " " >>$runScript
echo "projectName=$(echo ${PWD##*/})" >>$runScript
echo "#Compile project ..." >>$runScript
echo "rebar compile" >>$runScript
echo "#--------Success compile project!--------">>$runScript
echo " " >>$runScript
echo "#Deployment project ..." >>$runScript
echo "erl -pa ebin -pa deps*">>}],
[],waiting,<<>>,undefined,false,waiting,[],<<>>,undefined}
echo "---SUCCESS mk_runScript!"
}
if [ ! -d ${projectName} ] ; then
mkdir ${projectName}
cd ${projectName}
mk_app
change_erlang_app
bootFile
includeDir
privDir
testDir
depsDir
mkHandler
mk_runScript
fi
2、运行服务
sh run.sh
3、测试
curl http://localhost:8080
4、最终效果:
Erlang/OTP 17 [erts-6.0] [source] [smp:4:4] [async-threads:10][kernel-poll:false]
Eshell V6.0 (abort with ^G)
1> Req:{http_req,#Port<0.1286>,ranch_tcp,keepalive,<0.155.0>,<<"GET">>,
'HTTP/1.1',
{{127,0,0,1},46617},
<<"localhost">>,undefined,8080,<<"/">>,undefined,<<>>,[],
[{<<"user-agent">>,<<"curl/7.35.0">>},
{<<"host">>,<<"localhost:8080">>},
{<<"accept">>,<<"*/*">>}],
[],waiting,<<>>,undefined,false,waiting,[],<<>>,undefined}
mk_runScript(){
goProjectPath
echo "#!/bin/bash" >>$runScript
echo "# this is erlang template runScript!!">>$runScript
echo " " >>$runScript
echo "projectName=$(echo ${PWD##*/})" >>$runScript
echo "#Compile project ..." >>$runScript
echo "rebar compile" >>$runScript
echo "#--------Success compile project!--------">>$runScript
echo " " >>$runScript
echo "#Deployment project ..." >>$runScript
echo "erl -pa ebin -pa deps*">>}],
echo "---SUCCESS mk_runScript!"
}
if [ ! -d ${projectName} ] ; then
mkdir ${projectName}
cd ${projectName}
mk_app
change_erlang_app
bootFile
includeDir
privDir
testDir
depsDir
mkHandler
mk_runScript
fi
2、运行服务
sh run.sh
3、测试
curl http://localhost:8080
4、最终效果:
Erlang/OTP 17 [erts-6.0] [source] [smp:4:4] [async-threads:10][kernel-poll:false]
Eshell V6.0
1> Req:{http_req,#Port<0.1286>,ranch_tcp,keepalive,<0.155.0>,<<"GET">>,