# Homebrew Formula Template. Built by Makefile: `make fomula` # This is part of Application Builder. # https://github.com/golift/application-builder # This file is used when FORMULA is set to 'service'. class {{Class}} < Formula desc "{{Desc}}" homepage "{{URL}}" url "{{SOURCE_PATH}}" sha256 "{{SHA256}}" head "{{SOURCE_URL}}" depends_on "go" => :build depends_on "dep" def install ENV["GOPATH"] = buildpath bin_path = buildpath/"src/{{IMPORT_PATH}}" # Copy all files from their current location (GOPATH root) # to $GOPATH/src/{{IMPORT_PATH}} bin_path.install Dir["*",".??*"] cd bin_path do system "dep", "ensure", "--vendor-only" system "make", "install", "VERSION=#{version}", "ITERATION={{Iter}}", "PREFIX=#{prefix}", "ETC=#{etc}" # If this fails, the user gets a nice big warning about write permissions on their # #{var}/log folder. The alternative could be letting the app silently fail # to start when it cannot write logs. This is better. Fix perms; reinstall. touch("#{var}/log/#{name}.log") end end def caveats <<-EOS Edit the config file at #{etc}/#{name}/{{CONFIG_FILE}} then start #{name} with brew services start #{name} ~ log file: #{var}/log/#{name}.log The manual explains the config file options: man #{name} EOS end plist_options :startup => false def plist <<-EOS Label #{plist_name} ProgramArguments #{bin}/#{name} --config #{etc}/#{name}/{{CONFIG_FILE}} RunAtLoad KeepAlive StandardErrorPath #{var}/log/#{name}.log StandardOutPath #{var}/log/#{name}.log EOS end test do assert_match "#{name} v#{version}", shell_output("#{bin}/#{name} -v 2>&1", 2) end end