Permalink
Browse files

clean up

  • Loading branch information...
1 parent a5e40d5 commit 284a4c4ec410a6091e4ac8b34eaf7e46a40f2c01 @jsierles committed Mar 7, 2012
Showing with 82 additions and 0 deletions.
  1. +4 −0 runit/attributes/sv_bin.rb
  2. +59 −0 runit/definitions/runit_service.rb
  3. +4 −0 runit/metadata.rb
  4. +15 −0 runit/recipes/default.rb
@@ -0,0 +1,4 @@
+runit_sv_bin "/usr/bin/sv"
+
+runit_service_dir "/etc/service"
+runit_sv_dir "/etc/sv"
@@ -0,0 +1,59 @@
+define :runit_service, :directory => nil, :only_if => false, :options => {} do
+ params[:directory] ||= node[:runit_sv_dir]
+
+ sv_dir_name = "#{params[:directory]}/#{params[:name]}"
+ template_source = params[:template_name] || params[:name]
+
+ directory sv_dir_name do
+ mode 0755
+ recursive true
+ action :create
+ end
+
+ directory "#{sv_dir_name}/log" do
+ mode 0755
+ action :create
+ end
+
+ directory "#{sv_dir_name}/log/main" do
+ mode 0755
+ action :create
+ end
+
+ service params[:name]
+
+ template "#{sv_dir_name}/run" do
+ mode 0755
+ cookbook(params[:cookbook]) if params[:cookbook]
+ source "sv-#{template_source}-run.erb"
+ variables(params[:options])
+ notifies :restart, resources(:service => params[:name])
+ end
+
+ template "#{sv_dir_name}/log/run" do
+ mode 0755
+ cookbook(params[:cookbook]) if params[:cookbook]
+ source "sv-#{template_source}-log-run.erb"
+ variables(params[:options])
+ notifies :restart, resources(:service => params[:name])
+ end
+
+ link "/etc/init.d/#{params[:name]}" do
+ to node[:runit_sv_bin]
+ end
+
+ link "#{node[:runit_service_dir]}/#{params[:name]}" do
+ to "#{sv_dir_name}"
+ end
+
+ service params[:name] do
+ supports :restart => true, :status => true
+ action :nothing
+ end
+
+ #execute "#{params[:name]}-down" do
+ # command "/etc/init.d/#{params[:name]} down"
+ # only_if do params[:only_if] end
+ #end
+
+end
View
@@ -0,0 +1,4 @@
+maintainer "Joshua Sierles"
+maintainer_email "joshua@diluvia.net"
+description "Configures runit"
+version "0.1"
View
@@ -0,0 +1,15 @@
+execute "start-runsvdir" do
+ command "start runsvdir"
+ action :nothing
+end
+
+directory node[:runit_service_dir] do
+ mode 0755
+ recursive true
+ action :create
+end
+
+package "runit" do
+ action :install
+ notifies :run, resources(:execute => "start-runsvdir")
+end

0 comments on commit 284a4c4

Please sign in to comment.