Skip to content
This repository has been archived by the owner on Jan 27, 2019. It is now read-only.

Commit

Permalink
Added runit support
Browse files Browse the repository at this point in the history
  • Loading branch information
gansbrest committed Jun 6, 2013
1 parent f9aa871 commit 4921f7f
Show file tree
Hide file tree
Showing 7 changed files with 20 additions and 175 deletions.
1 change: 1 addition & 0 deletions attributes/default.rb
Expand Up @@ -9,6 +9,7 @@
default["statsd"]["graphite_port"] = 2003 default["statsd"]["graphite_port"] = 2003
default["statsd"]["delete_timers"] = false default["statsd"]["delete_timers"] = false
default["statsd"]["delete_gauges"] = false default["statsd"]["delete_gauges"] = false
default["statsd"]["username"] = "statsd"


# Graphite storage config # Graphite storage config
default["statsd"]["graphite"]["legacy_namespace"] = true default["statsd"]["graphite"]["legacy_namespace"] = true
Expand Down
2 changes: 1 addition & 1 deletion metadata.rb
Expand Up @@ -6,7 +6,7 @@
recipe "statsd", "Installs and configures StatsD" recipe "statsd", "Installs and configures StatsD"
name "statsd" name "statsd"


%w{ git logrotate nodejs }.each do |d| %w{ git logrotate nodejs runit }.each do |d|
depends d depends d
end end


Expand Down
52 changes: 12 additions & 40 deletions recipes/default.rb
@@ -1,11 +1,12 @@
include_recipe "git" include_recipe "git"
include_recipe "nodejs" include_recipe "nodejs"
include_recipe "logrotate" include_recipe "logrotate"
include_recipe "runit"


git node["statsd"]["dir"] do git node["statsd"]["dir"] do
repository node["statsd"]["repository"] repository node["statsd"]["repository"]
action :sync action :sync
notifies :restart, "service[statsd]" notifies :restart, "runit_service[statsd]"
end end


directory node["statsd"]["conf_dir"] do directory node["statsd"]["conf_dir"] do
Expand All @@ -30,41 +31,14 @@
:prefix_gauge => node["statsd"]["graphite"]["prefix_gauge"], :prefix_gauge => node["statsd"]["graphite"]["prefix_gauge"],
:prefix_set => node["statsd"]["graphite"]["prefix_set"] :prefix_set => node["statsd"]["graphite"]["prefix_set"]
) )
notifies :restart, "service[statsd]" notifies :restart, "runit_service[statsd]"
end end



user "#{node['statsd']['username']}" do
case node["platform_family"]
when "debian"
template "/etc/init/statsd.conf" do
mode "0644"
source "statsd.conf.erb"
variables(
:log_file => node["statsd"]["log_file"],
:platform_version => node["platform_version"].to_f
)
end
when "rhel","fedora"
template "/etc/init.d/statsd" do
mode "0755"
source "statsd.erb"
variables(
:log_file => node["statsd"]["log_file"],
:node_dir => node["statsd"]["dir"]
)
end
end

user "statsd" do
system true system true
shell "/bin/false" shell "/bin/false"
end end


file node["statsd"]["log_file"] do
owner "statsd"
action :create
end

logrotate_app "statsd" do logrotate_app "statsd" do
cookbook "logrotate" cookbook "logrotate"
path node["statsd"]["log_file"] path node["statsd"]["log_file"]
Expand All @@ -73,14 +47,12 @@
create "644 root root" create "644 root root"
end end


service "statsd" do runit_service "statsd" do
case node["platform"] action [:enable, :start]
when "ubuntu" default_logger true
if node["platform_version"].to_f >= 9.10 options ({
provider Chef::Provider::Service::Upstart :user => node['statsd']['username'],
end :statsd_dir => node['statsd']['dir'],
#restart_command "sudo service statsd stop && sudo service statsd start" :conf_dir => node['statsd']['conf_dir']
end })
action [ :enable, :start ]
supports :start => true, :stop => true, :restart => true, :status => true
end end
23 changes: 0 additions & 23 deletions templates/default/statsd.conf.erb

This file was deleted.

111 changes: 0 additions & 111 deletions templates/default/statsd.erb

This file was deleted.

2 changes: 2 additions & 0 deletions templates/default/sv-statsd-log-run.erb
@@ -0,0 +1,2 @@
#!/bin/sh
exec svlogd -tt ./main
4 changes: 4 additions & 0 deletions templates/default/sv-statsd-run.erb
@@ -0,0 +1,4 @@
#!/bin/sh
exec 2>&1
exec chpst -u <%= @options['user'] %> /usr/local/bin/node <%= @options['statsd_dir'] %>/stats.js <%= @options['conf_dir'] %>/config.js

0 comments on commit 4921f7f

Please sign in to comment.