2016-07-06 18:55:59 +00:00
|
|
|
require "language/node"
|
|
|
|
|
|
|
|
class Grafana < Formula
|
|
|
|
desc "Gorgeous metric visualizations and dashboards for timeseries databases."
|
|
|
|
homepage "http://grafana.org"
|
|
|
|
url "https://github.com/grafana/grafana/archive/v3.1.1.tar.gz"
|
|
|
|
sha256 "77bff57f02e507fb998d6d2492798801db4cb10c82c1378e32bd1dde963dba3d"
|
|
|
|
|
|
|
|
head "https://github.com/grafana/grafana.git"
|
|
|
|
|
2016-08-09 06:31:06 +00:00
|
|
|
bottle do
|
|
|
|
cellar :any_skip_relocation
|
2016-08-12 01:07:07 +00:00
|
|
|
revision 1
|
|
|
|
sha256 "0a188a184ad09b6c6a5b66350d8563ef47c81cf360d807ec5b76006777d9d205" => :el_capitan
|
|
|
|
sha256 "426a722b7bdba4eb0f9004296c056df3aa06c27f4d58728f3985ede035aa5fff" => :yosemite
|
|
|
|
sha256 "96701f8bcc4ccbbcceb316084fe26ff7bd5ba9a478b5fb04fc8aadfa4361908e" => :mavericks
|
2016-08-09 06:31:06 +00:00
|
|
|
end
|
|
|
|
|
2016-07-06 18:55:59 +00:00
|
|
|
depends_on "go" => :build
|
|
|
|
depends_on "node" => :build
|
|
|
|
|
|
|
|
def install
|
|
|
|
ENV["GOPATH"] = buildpath
|
|
|
|
grafana_path = buildpath/"src/github.com/grafana/grafana"
|
|
|
|
grafana_path.install buildpath.children
|
|
|
|
|
|
|
|
cd grafana_path do
|
|
|
|
system "go", "run", "build.go", "setup"
|
|
|
|
system "go", "run", "build.go", "build"
|
|
|
|
system "npm", "install", *Language::Node.local_npm_install_args
|
|
|
|
system "npm", "install", "grunt-cli", *Language::Node.local_npm_install_args
|
|
|
|
system "node_modules/grunt-cli/bin/grunt", "build"
|
|
|
|
|
|
|
|
bin.install "bin/grafana-cli"
|
|
|
|
bin.install "bin/grafana-server"
|
|
|
|
(etc/"grafana").mkpath
|
|
|
|
cp("conf/sample.ini", "conf/grafana.ini.example")
|
|
|
|
etc.install "conf/sample.ini" => "grafana/grafana.ini"
|
|
|
|
etc.install "conf/grafana.ini.example" => "grafana/grafana.ini.example"
|
|
|
|
pkgshare.install "conf", "vendor"
|
|
|
|
pkgshare.install "public_gen" => "public"
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
def post_install
|
|
|
|
(var/"log/grafana").mkpath
|
|
|
|
(var/"lib/grafana/plugins").mkpath
|
|
|
|
end
|
|
|
|
|
2016-09-24 15:45:48 +00:00
|
|
|
plist_options :manual => "grafana-server --config=#{HOMEBREW_PREFIX}/etc/grafana/grafana.ini --homepath #{HOMEBREW_PREFIX}/share/grafana cfg:default.paths.logs=#{HOMEBREW_PREFIX}/var/log/grafana cfg:default.paths.data=#{HOMEBREW_PREFIX}/var/lib/grafana cfg:default.paths.plugins=#{HOMEBREW_PREFIX}/var/lib/grafana/plugins"
|
2016-07-06 18:55:59 +00:00
|
|
|
|
|
|
|
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>KeepAlive</key>
|
|
|
|
<dict>
|
|
|
|
<key>SuccessfulExit</key>
|
|
|
|
<false/>
|
|
|
|
</dict>
|
|
|
|
<key>Label</key>
|
|
|
|
<string>#{plist_name}</string>
|
|
|
|
<key>ProgramArguments</key>
|
|
|
|
<array>
|
|
|
|
<string>#{opt_bin}/grafana-server</string>
|
|
|
|
<string>--config</string>
|
|
|
|
<string>#{etc}/grafana/grafana.ini</string>
|
|
|
|
<string>--homepath</string>
|
|
|
|
<string>#{opt_pkgshare}</string>
|
|
|
|
<string>cfg:default.paths.logs=#{var}/log/grafana</string>
|
|
|
|
<string>cfg:default.paths.data=#{var}/lib/grafana</string>
|
|
|
|
<string>cfg:default.paths.plugins=#{var}/lib/grafana/plugins</string>
|
|
|
|
</array>
|
|
|
|
<key>RunAtLoad</key>
|
|
|
|
<true/>
|
|
|
|
<key>WorkingDirectory</key>
|
2016-08-12 00:40:26 +00:00
|
|
|
<string>#{var}/lib/grafana</string>
|
2016-07-06 18:55:59 +00:00
|
|
|
<key>StandardErrorPath</key>
|
|
|
|
<string>#{var}/log/grafana/grafana-stderr.log</string>
|
|
|
|
<key>StandardOutPath</key>
|
|
|
|
<string>#{var}/log/grafana/grafana-stdout.log</string>
|
|
|
|
<key>SoftResourceLimits</key>
|
|
|
|
<dict>
|
|
|
|
<key>NumberOfFiles</key>
|
|
|
|
<integer>10240</integer>
|
|
|
|
</dict>
|
|
|
|
</dict>
|
|
|
|
</plist>
|
|
|
|
EOS
|
|
|
|
end
|
|
|
|
|
|
|
|
test do
|
|
|
|
require "pty"
|
|
|
|
require "timeout"
|
|
|
|
|
|
|
|
# first test
|
|
|
|
system bin/"grafana-server", "-v"
|
|
|
|
|
|
|
|
# avoid stepping on anything that may be present in this directory
|
|
|
|
tdir = File.join(Dir.pwd, "grafana-test")
|
|
|
|
Dir.mkdir(tdir)
|
|
|
|
logdir = File.join(tdir, "log")
|
|
|
|
datadir = File.join(tdir, "data")
|
|
|
|
plugdir = File.join(tdir, "plugins")
|
|
|
|
[logdir, datadir, plugdir].each do |d|
|
|
|
|
Dir.mkdir(d)
|
|
|
|
end
|
|
|
|
Dir.chdir(pkgshare)
|
|
|
|
|
|
|
|
res = PTY.spawn(bin/"grafana-server", "cfg:default.paths.logs=#{logdir}", "cfg:default.paths.data=#{datadir}", "cfg:default.paths.plugins=#{plugdir}", "cfg:default.server.http_port=50100")
|
|
|
|
r = res[0]
|
|
|
|
w = res[1]
|
|
|
|
pid = res[2]
|
|
|
|
|
|
|
|
listening = Timeout.timeout(5) do
|
|
|
|
li = false
|
|
|
|
r.each do |l|
|
|
|
|
if l =~ /Listen/
|
|
|
|
li = true
|
|
|
|
break
|
|
|
|
end
|
|
|
|
end
|
|
|
|
li
|
|
|
|
end
|
|
|
|
|
|
|
|
Process.kill("TERM", pid)
|
|
|
|
w.close
|
|
|
|
r.close
|
|
|
|
listening
|
|
|
|
end
|
|
|
|
end
|