From 2655a001c9e05aec1cad806803b00566b8b4a249 Mon Sep 17 00:00:00 2001 From: Alexander Pakulov Date: Sat, 17 Sep 2016 18:04:34 -0500 Subject: [PATCH] linkerd 0.8.1 (new formula) Closes #4827. Signed-off-by: Mike McQuaid --- Formula/linkerd.rb | 83 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 83 insertions(+) create mode 100644 Formula/linkerd.rb diff --git a/Formula/linkerd.rb b/Formula/linkerd.rb new file mode 100644 index 0000000000..491b5cc0e0 --- /dev/null +++ b/Formula/linkerd.rb @@ -0,0 +1,83 @@ +class Linkerd < Formula + desc "Drop-in RPC proxy designed for microservices" + homepage "http://linkerd.io/" + url "https://github.com/BuoyantIO/linkerd/releases/download/0.8.1/linkerd-0.8.1.tgz" + sha256 "d8fe77daaf0a7d261a96dd4dc360a1045ae6d302134ab5c7628754e4f4dc781c" + + bottle :unneeded + + depends_on :java => "1.8+" + + def install + inreplace "config/linkerd.yaml", "disco", etc/"linkerd/disco" + + libexec.install "linkerd-#{version}-exec" + bin.install_symlink libexec/"linkerd-#{version}-exec" => "linkerd" + + pkgshare.mkpath + cp buildpath/"config/linkerd.yaml", pkgshare/"default.yaml" + + etc.install "config" => "linkerd" + etc.install "disco" => "linkerd/disco" + libexec.install_symlink etc/"linkerd" => "config" + libexec.install_symlink etc/"linkerd/disco" => "disco" + + share.install "docs" + end + + def post_install + (var/"log/linkerd").mkpath + end + + plist_options manual: "linkerd #{HOMEBREW_PREFIX}/etc/linkerd/linkerd.yaml" + + def plist; <<-EOS.undent + + + + + Label + #{plist_name} + WorkingDirectory + #{HOMEBREW_PREFIX} + ProgramArguments + + #{opt_bin}/linkerd + #{etc}/linkerd/linkerd.yaml + + RunAtLoad + + KeepAlive + + StandardErrorPath + #{var}/log/linkerd/linkerd.log + StandardOutPath + #{var}/log/linkerd/linkerd.log + + + EOS + end + + test do + (testpath/"index.html").write "It works!" + + simple_http_pid = fork do + exec "python -m SimpleHTTPServer 9999" + end + linkerd_pid = fork do + exec "#{bin}/linkerd #{pkgshare}/default.yaml" + end + + sleep 5 + + begin + assert_match /It works!/, shell_output("curl -s -H 'Host: web' http://localhost:4140") + assert_match /Bad Gateway/, shell_output("curl -s -I -H 'Host: foo' http://localhost:4140") + ensure + Process.kill("TERM", linkerd_pid) + Process.wait(linkerd_pid) + Process.kill("TERM", simple_http_pid) + Process.wait(simple_http_pid) + end + end +end