Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

COOK-356, extend runit_service w/ env support

* with parameter :env to support environment variables for runit services
  • Loading branch information...
commit da585f7296bf2193ecc972ec0b1dfcd841b586a8 1 parent 69a117f
@mmarschall mmarschall authored jtimberman committed
Showing with 15 additions and 1 deletion.
  1. +15 −1 definitions/runit_service.rb
View
16 definitions/runit_service.rb
@@ -17,7 +17,7 @@
# limitations under the License.
#
-define :runit_service, :directory => nil, :only_if => false, :finish_script => false, :control => [], :run_restart => true, :active_directory => nil, :owner => "root", :group => "root", :template_name => nil, :start_command => "start", :stop_command => "stop", :restart_command => "restart", :status_command => "status", :options => Hash.new do
+define :runit_service, :directory => nil, :only_if => false, :finish_script => false, :control => [], :run_restart => true, :active_directory => nil, :owner => "root", :group => "root", :template_name => nil, :start_command => "start", :stop_command => "stop", :restart_command => "restart", :status_command => "status", :options => Hash.new, :env => Hash.new do
include_recipe "runit"
params[:directory] ||= node[:runit][:sv_dir]
@@ -26,6 +26,7 @@
sv_dir_name = "#{params[:directory]}/#{params[:name]}"
service_dir_name = "#{params[:active_directory]}/#{params[:name]}"
+ params[:options].merge!(:env_dir => "#{sv_dir_name}/env") unless params[:env].empty?
directory sv_dir_name do
owner params[:owner]
@@ -70,6 +71,19 @@
end
end
+ unless params[:env].empty?
+ directory "#{sv_dir_name}/env" do
+ mode 0755
+ action :create
+ end
+
+ params[:env].each do |var, value|
+ file "#{sv_dir_name}/env/#{var}" do
+ content value
+ end
+ end
+ end
+
if params[:finish_script]
template "#{sv_dir_name}/finish" do
owner params[:owner]
Please sign in to comment.
Something went wrong with that request. Please try again.