/
openresty.rb
98 lines (87 loc) · 3.47 KB
/
openresty.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
class Openresty < Formula
homepage "http://openresty.org"
url "https://openresty.org/download/ngx_openresty-1.9.3.1.tar.gz"
sha256 "dbcfd21f84431a7d13fe3c3656dcd9dd81236a8f7a114ac8d4afb86665f788bb"
depends_on "pcre"
depends_on "openssl"
depends_on "drizzle" => :optional
depends_on "postgresql" => :optional
depends_on "geoip" => :optional
# nginx options
option "without-luajit", "Compile *without* support for the Lua Just-In-Time Compiler"
option "with-drizzle", "Compile with support for direct communication with Drizzle database servers"
option "with-postgresql", "Compile with support for direct communication with PostgreSQL database servers"
option "with-iconv", "Compile with support for converting character encodings"
option "with-debug", "Compile with support for debug logging but without proper gdb debugging symbols"
# nginx options
option "with-webdav", "Compile with ngx_http_dav_module"
option "with-gunzip", "Compile with ngx_http_gunzip_module"
option "with-geoip", "Compile with ngx_http_geoip_module"
option "with-stub_status", "Compile with ngx_http_stub_status_module"
def install
# Configure
cc_opt = "-I#{HOMEBREW_PREFIX}/include"
ld_opt = "-L#{HOMEBREW_PREFIX}/lib"
args = [
"--prefix=#{prefix}",
"--pid-path=#{var}/run/openresty.pid",
"--lock-path=#{var}/run/openresty.lock",
"--sbin-path=#{bin}/openresty",
"--conf-path=#{etc}/openresty/nginx.conf",
"--http-log-path=#{var}/log/nginx/access.log",
"--error-log-path=#{var}/log/nginx/error.log",
"--with-pcre",
"--with-pcre-jit",
"--with-cc-opt=#{cc_opt}",
"--with-ld-opt=#{ld_opt}"
]
# OpenResty options
args << "--with-lua51" if build.without? "luajit"
args << "--with-http_dav_module" if build.with? "webdav"
args << "--with-http_gunzip_module" if build.with? "gunzip"
args << "--with-http_geoip_module" if build.with? "geoip"
args << "--with-http_stub_status_module" if build.with? "stub_status"
args << "--with-http_drizzle_module" if build.with? "drizzle"
args << "--with-http_postgres_module" if build.with? "postgresql"
args << "--with-http_iconv_module" if build.with? "iconv"
# Debugging mode, unfortunately without debugging symbols
if build.with? "debug"
args << "--with-debug"
args << "--with-dtrace-probes"
args << "--with-no-pool-patch"
# this allows setting of `debug.sethook` in luajit
unless build.without? "luajit"
args << "--with-luajit-xcflags=-DLUAJIT_ENABLE_CHECKHOOK"
end
opoo "Openresty will be built --with-debug option, but without debugging symbols."\
"For debugging symbols you have to compile it by hand."
end
system "./configure", *args
# Install
system "make"
system "make install"
end
def plist; <<-EOS.undent
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Label</key>
<string>#{plist_name}</string>
<key>RunAtLoad</key>
<true/>
<key>KeepAlive</key>
<false/>
<key>ProgramArguments</key>
<array>
<string>#{opt_prefix}/bin/openresty</string>
<string>-g</string>
<string>daemon off;</string>
</array>
<key>WorkingDirectory</key>
<string>#{HOMEBREW_PREFIX}</string>
</dict>
</plist>
EOS
end
end