graylog2-server: add launchd plist

Signed-off-by: Adam Vandenberg <flangy@gmail.com>
master
Marc Abramowitz 2012-04-08 09:58:07 -07:00 committed by Adam Vandenberg
parent c757157a84
commit a8da2128bf
1 changed files with 58 additions and 8 deletions

View File

@ -22,24 +22,74 @@ class Graylog2Server < Formula
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.
To start graylog2-server:
graylog2ctl start
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}
To stop graylog2-server:
graylog2ctl stop
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}
The config file is located at:
#{etc}/graylog2.conf
Or to manage graylog2-server without launchd:
To start graylog2-server:
graylog2ctl start
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