Permalink
Browse files

graylog2-server: add launchd plist

Signed-off-by: Adam Vandenberg <flangy@gmail.com>
  • Loading branch information...
1 parent c91973b commit b1f1f58a506a3c6946c9388e3356f1b4c8345b27 @msabramo msabramo committed with adamv Apr 8, 2012
Showing with 58 additions and 8 deletions.
  1. +58 −8 Library/Formula/graylog2-server.rb
@@ -22,24 +22,74 @@ def install
etc.install "graylog2.conf"
prefix.install Dir['*']
+
+ plist_path.write startup_plist
+ plist_path.chmod 0644
end
def caveats
<<-EOS.undent
- In the interest of allowing you to run `graylog2ctl`
- without `sudo`, the default port is set to 8514.
+ In the interest of allowing you to run graylog2-server as a
+ non-root user, the default syslog_listen_port is set to 8514.
+
+ If this is your first install, automatically load on login with:
+ mkdir -p ~/Library/LaunchAgents
+ cp #{plist_path} ~/Library/LaunchAgents/
+ launchctl load -w ~/Library/LaunchAgents/#{plist_path.basename}
+
+ If this is an upgrade and you already have the #{plist_path.basename} loaded:
+ launchctl unload -w ~/Library/LaunchAgents/#{plist_path.basename}
+ cp #{plist_path} ~/Library/LaunchAgents/
+ launchctl load -w ~/Library/LaunchAgents/#{plist_path.basename}
- To start graylog2-server:
- graylog2ctl start
+ Or to manage graylog2-server without launchd:
- To stop graylog2-server:
- graylog2ctl stop
+ To start graylog2-server:
+ graylog2ctl start
- The config file is located at:
- #{etc}/graylog2.conf
+ To stop graylog2-server:
+ graylog2ctl stop
+
+ The config file is located at:
+ #{etc}/graylog2.conf
EOS
end
+ def startup_plist
+ return <<-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>java</string>
+ <string>-jar</string>
+ <string>#{prefix}/graylog2-server.jar</string>
+ <string>-f</string>
+ <string>#{etc}/graylog2.conf</string>
+ <string>-p</string>
+ <string>/tmp/graylog2.pid</string>
+ </array>
+ <key>RunAtLoad</key>
+ <true/>
+ <key>KeepAlive</key>
+ <false/>
+ <key>UserName</key>
+ <string>#{`whoami`.chomp}</string>
+ <key>WorkingDirectory</key>
+ <string>#{HOMEBREW_PREFIX}</string>
+ <key>StandardErrorPath</key>
+ <string>#{var}/log/graylog2-server/error.log</string>
+ <key>StandardOutPath</key>
+ <string>#{var}/log/graylog2-server/output.log</string>
+</dict>
+</plist>
+EOS
+ end
+
def test
system "#{bin}/graylog2ctl"
end

0 comments on commit b1f1f58

Please sign in to comment.