Skip to content

Instantly share code, notes, and snippets.

@toritori0318
Last active September 26, 2022 18:21
Show Gist options
  • Save toritori0318/2f2e080f906dbbbd0dea to your computer and use it in GitHub Desktop.
Save toritori0318/2f2e080f906dbbbd0dea to your computer and use it in GitHub Desktop.
isucon4 Lapis版 Itamaeレシピ
# attributes
pcre_version='8.36'
openresty_version='1.7.7.1'
openresty_prefix='/opt/openresty'
luarocks_version='2.0.13'
########################################
# iscon bashrc
execute "add bashrc" do
command <<-"EOH"
echo 'export PATH=/opt/openresty/luajit/bin:$PATH' >> /home/isucon/.bashrc
echo 'export PATH=/opt/openresty/nginx/sbin:$PATH' >> /home/isucon/.bashrc
echo 'export LAPIS_OPENRESTY=/opt/openresty' >> /home/isucon/.bashrc
EOH
not_if "grep -q LAPIS_OPENRESTY /home/isucon/.bashrc"
end
########################################
# package install
execute "yum groupinstall -y 'Development Tools'"
package "openssl-devel" do
action :install
end
########################################
# openresty
execute "install openresty" do
command <<-"EOH"
cd /tmp
wget ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/pcre-#{pcre_version}.tar.gz
tar zxf pcre-#{pcre_version}.tar.gz
wget http://openresty.org/download/ngx_openresty-#{openresty_version}.tar.gz
tar zxf ngx_openresty-#{openresty_version}.tar.gz
cd ngx_openresty-#{openresty_version}
export PATH=/sbin:$PATH
./configure --with-luajit --prefix=#{openresty_prefix} --with-http_gzip_static_module --with-pcre=/tmp/pcre-#{pcre_version} --with-pcre-jit
make
make install
EOH
not_if "test -e #{openresty_prefix}"
end
########################################
# openresty + luarocks
execute "install luarocks" do
command <<-"EOH"
cd /tmp
wget http://luarocks.org/releases/luarocks-#{luarocks_version}.tar.gz
tar -xzvf luarocks-#{luarocks_version}.tar.gz
cd luarocks-#{luarocks_version}/
./configure --prefix=#{openresty_prefix}/luajit \
--with-lua=#{openresty_prefix}/luajit/ \
--lua-suffix=jit-2.1.0-alpha \
--with-lua-include=#{openresty_prefix}/luajit/include/luajit-2.1
make
make install
EOH
not_if "test -e #{openresty_prefix}/luajit/bin/luarocks"
end
link "/usr/bin/luarocks" do
to "#{openresty_prefix}/luajit/bin/luarocks"
end
########################################
# install luasec
execute "luarocks install luaSec OPENSSL_LIBDIR=/usr/lib64"
# install luarocks module
luarocks_pkg = %w{
moonscript
inspect
}
luarocks_pkg.each do |pkg|
execute "luarocks install #{pkg}"
end
########################################
# install lapis
git "/tmp/lapis" do
repository "https://github.com/yingted/lapis.git"
end
# patch
execute "patch of lapis-mysql" do
command <<-"EOH"
cd /tmp/lapis/lapis/nginx
cat << _EOP_ | patch -f
*** db.moon-org 2015-01-02 16:42:37.312736290 +0000
--- db.moon 2015-01-02 16:42:50.200382486 +0000
***************
*** 135,140 ****
--- 135,141 ----
logger = require "lapis.logging"
init_db = ->
+ config = require("lapis.config").get!
default_backend = config.mysql and (config.mysql.backend or "resty_mysql")
default_backend = default_backend or (config.postgres and config.postgres.backend)
default_backend = default_backend or "default"
_EOP_
EOH
not_if "test -e #{openresty_prefix}/luajit/bin/lapis"
end
# make install
execute "install lapis(mysql ver)" do
command <<-"EOH"
cd /tmp/lapis
PATH=/opt/openresty/luajit/bin:$PATH make global
EOH
not_if "test -e #{openresty_prefix}/luajit/bin/lapis"
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment