Skip to content

Commit

Permalink
graylog2-server: add launchd plist
Browse files Browse the repository at this point in the history
Signed-off-by: Adam Vandenberg <flangy@gmail.com>
  • Loading branch information
msabramo authored and adamv committed Apr 8, 2012
1 parent c91973b commit b1f1f58
Showing 1 changed file with 58 additions and 8 deletions.
66 changes: 58 additions & 8 deletions Library/Formula/graylog2-server.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit b1f1f58

Please sign in to comment.