Refactor router v2. Move lua module code into router directory. Remove unused plugins from nginx.

Change-Id: Ia047aaa80a45a3a55e726fe7ef17d45edc3ac516
This commit is contained in:
anferneeg 2012-02-17 03:12:01 -08:00
Родитель 97f4c8cc28
Коммит 9df59fd1cd
4 изменённых файлов: 5 добавлений и 56 удалений

Просмотреть файл

@ -14,11 +14,9 @@ default[:lua][:version] = "5.1.4"
default[:lua][:simple_version] = lua[:version].match(/\d+\.\d+/).to_s # something like 5.1
default[:lua][:source] = "http://www.lua.org/ftp/lua-#{lua[:version]}.tar.gz"
default[:lua][:path] = File.join(node[:deployment][:home], "deploy", "lua", "lua-#{lua[:version]}")
default[:lua][:openssl_source] = "https://github.com/zhaozg/lua-openssl/tarball/0.1.1"
default[:lua][:cjson_source] = "http://www.kyne.com.au/~mark/software/lua-cjson-1.0.3.tar.gz"
default[:lua][:base64_source] = "http://www.tecgraf.puc-rio.br/~lhf/ftp/lua/5.1/lbase64.tar.gz"
default[:lua][:module_path] = File.join(lua[:path], 'lib', 'lua', lua[:simple_version])
default[:lua][:plugin_source_path] = File.join(node["cloudfoundry"]["path"], "router", "ext", "nginx")
default[:nginx][:worker_connections] = 2048
default[:nginx][:uls_ip] = "localhost"

Просмотреть файл

@ -28,18 +28,6 @@ when "ubuntu"
not_if { ::File.exists?(File.join("", "tmp", "lua-#{lua_version}.tar.gz")) }
end
remote_file File.join("", "tmp", "lua-openssl-0.1.1.tar.gz") do
owner node[:deployment][:user]
source node[:lua][:openssl_source]
not_if { ::File.exists?(File.join("", "tmp", "lua-openssl-0.1.1.tar.gz")) }
end
remote_file File.join("", "tmp", "lbase64.tar.gz") do
owner node[:deployment][:user]
source node[:lua][:base64_source]
not_if { ::File.exists?(File.join("", "tmp", "lbase64.tar.gz")) }
end
remote_file File.join("", "tmp", "lua-cjson-1.0.3.tar.gz") do
owner node[:deployment][:user]
source node[:lua][:cjson_source]
@ -112,22 +100,6 @@ when "ubuntu"
end
end
bash "Install lua openssl" do
cwd File.join("", "tmp")
user node[:deployment][:user]
code <<-EOH
tar xzf lua-openssl-0.1.1.tar.gz
cd zhaozg-lua-openssl-5ecb647
sed 's!^PREFIX=.*!PREFIX='#{lua_path}'!' config > tmp
sed 's!^CC=.*!CC= gcc $(CFLAGS)!' tmp > config
make
make install
EOH
not_if do
::File.exists?(File.join(lua_module_path, "openssl.so"))
end
end
bash "Install lua json" do
cwd File.join("", "tmp")
user node[:deployment][:user]
@ -144,24 +116,6 @@ when "ubuntu"
end
end
bash "Install lua base64" do
cwd File.join("", "tmp")
user node[:deployment][:user]
code <<-EOH
tar xzf lbase64.tar.gz
cd base64
sed 's!^LUAINC=.*!LUAINC='#{lua_path}/include'!' Makefile > tmp
sed 's!^LUABIN=.*!LUABIN='#{lua_path}/bin'!' tmp > Makefile
sed 's!^CFLAGS=.*!CFLAGS= $(INCS) $(WARN) -fPIC -O2 $G!' Makefile > tmp
mv tmp Makefile
make
cp base64.so #{lua_module_path}
EOH
not_if do
::File.exists?(File.join(lua_module_path, "base64.so"))
end
end
bash "Install nginx" do
cwd File.join("", "tmp")
user node[:deployment][:user]
@ -195,14 +149,16 @@ when "ubuntu"
template "uls.lua" do
path File.join(lua_module_path, "uls.lua")
source "uls.lua.erb"
source File.join(node[:lua][:plugin_source_path], "uls.lua")
local true
owner node[:deployment][:user]
mode 0644
end
template "tablesave.lua" do
path File.join(lua_module_path, "tablesave.lua")
source "tablesave.lua"
source File.join(node[:lua][:plugin_source_path], "tablesave.lua")
local true
owner node[:deployment][:user]
mode 0644
end

Просмотреть файл

@ -5,8 +5,6 @@
--------------------------------------------------------------------------------
-- import dependencies
local openssl = require("openssl")
local base64 = require("base64")
local cjson = require("cjson")
require("tablesave")
@ -36,9 +34,6 @@ ULS_BACKEND_ADDR = "backend_addr"
ULS_REQEST_TAGS = "request_tags"
ULS_ROUTER_IP = "router_ip"
SESSION_KEY = "<%= node[:router][:session_key] %>"
TRACE_KEY = "<%= node[:router][:trace_key] %>"
--[[
Message between nginx and uls (as http body)
nginx -> uls