jtimberman/logstash-cookbook — pull request #1 by harlanbarnes (2011-12-20 22:34:47+00:00)
Title: Added support for init.d style startup using daemonize

Hi Joshua,

Here are some enhancements for your consideration. I used your cookbook to get me started on logstash agent and web and ended up adding these items for myself. If they are of any interest, have at them.

If you'd like some or all of them and would like me to re-work them, I'm happy to do it. Just interested in working on cookbooks and logstash is quickly becoming an important tool in our process.

- I changed the default version to logstash's latest (1.0.17)

- Changed attribute strings to symbols
# not sure if this is the "right" way to do it, but it seemed like a lot of the Opscode recipes did it this way, so I made this switch on my copy.

- Added :init_style and set it to runit to keep the current setup
# I followed a similar pattern to how the Opscode chef-client init style works.

- Added :init_style value for daemonize on redhat, centos, scientific. It uses init.d style startup and then will deamonize the java process
# Since the java process won't background itself, I had to use 'daemonize' from epel.

- Added many attributes for directory, user control, etc.
# I made each directory an attribute
# I added an optional attribute to point to grok's pattern directory (for adding custom patterns)
# I added control for creating a logstash user to run the processes.
# I also added memory settings for the agent and web.
# I also added an attribute to allow you to deploy the agent, the web or both
# If the component attribute has 'agent' it will deploy the simple agent.conf file
# I made attributes out of the elasticsearch values to demonstrate how you can switch from embedded elasticsearch to a separate elasticsearch installation

Note that the startup for both the runit and daemonize style point to a directory ([:logstash][:config_dir]). Logstash will glob up all configurations in the directory and concat them together.

My plan is to drop (and/or overwrite agent.conf) configurations for the logstash-agent to use into that directory and then "notify" the logstash-agent service for a restart to use them. That way I can use this cookbook as a "base" and just include it on nodes where I need to ship logs to the central location.