Permalink
Branch: master
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
77 lines (69 sloc) 1.92 KB
class Mongodb < Formula
desc "High-performance, schema-free, document-oriented database"
homepage "https://www.mongodb.com/"
url "https://fastdl.mongodb.org/osx/mongodb-osx-ssl-x86_64-4.0.5.tgz"
sha256 "3a7c5a60ab3b5d0614d44e64c02f3550ca1f639da1b618d2b566a0224108f67d"
bottle :unneeded
def install
prefix.install Dir["*"]
end
def post_install
(var/"mongodb").mkpath
(var/"log/mongodb").mkpath
if !(File.exist?((etc/"mongod.conf"))) then
(etc/"mongod.conf").write mongodb_conf
end
end
def mongodb_conf; <<~EOS
systemLog:
destination: file
path: #{var}/log/mongodb/mongo.log
logAppend: true
storage:
dbPath: #{var}/mongodb
net:
bindIp: 127.0.0.1
EOS
end
plist_options :manual => "mongod --config #{HOMEBREW_PREFIX}/etc/mongod.conf"
def plist; <<~EOS
<?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>ProgramArguments</key>
<array>
<string>#{opt_bin}/mongod</string>
<string>--config</string>
<string>#{etc}/mongod.conf</string>
</array>
<key>RunAtLoad</key>
<true/>
<key>KeepAlive</key>
<false/>
<key>WorkingDirectory</key>
<string>#{HOMEBREW_PREFIX}</string>
<key>StandardErrorPath</key>
<string>#{var}/log/mongodb/output.log</string>
<key>StandardOutPath</key>
<string>#{var}/log/mongodb/output.log</string>
<key>HardResourceLimits</key>
<dict>
<key>NumberOfFiles</key>
<integer>4096</integer>
</dict>
<key>SoftResourceLimits</key>
<dict>
<key>NumberOfFiles</key>
<integer>4096</integer>
</dict>
</dict>
</plist>
EOS
end
test do
system "#{bin}/mongod", "--sysinfo"
end
end