Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

various fixes to get perlbrew_service working

  • Loading branch information...
commit 437004594da977cdf26716d9d901554272dcec58 1 parent 10a4ba0
@dagolden dagolden authored
View
18 cookbooks/perlbrew/providers/service.rb
@@ -22,8 +22,6 @@
require 'chef/mixin/language'
include Chef::Mixin::ShellOut
-include_recipe "runit"
-
# XXX must be a fully qualified 'perl-5.X.Y@libname' style name
action :create do
perlbrew_env = {
@@ -31,15 +29,25 @@
'PERLBREW_HOME' => node['perlbrew']['perlbrew_root']
}
+ my_perlbrew = new_resource.perlbrew
+ my_cwd = new_resource.cwd
+ my_user = new_resource.user
+ my_group = new_resource.group
+ my_command = new_resource.command
+ my_env = new_resource.environment.merge(perlbrew_env)
+
runit_service new_resource.name do
template_name 'perlbrew-service'
cookbook 'perlbrew'
options(
:perlbrew_root => node['perlbrew']['perlbrew_root'],
- :resource => new_resource
+ :perlbrew => my_perlbrew,
+ :user => my_user,
+ :group => my_group,
+ :command => my_command,
+ :cwd => my_cwd
)
- env new_resource.environment.merge(perlbrew_env)
- run_restart false
+ env my_env
end
end
View
2  cookbooks/perlbrew/recipes/default.rb
@@ -23,6 +23,8 @@
package p
end
+include_recipe "runit"
+
perlbrew_root = node['perlbrew']['perlbrew_root']
perlbrew_bin = "#{perlbrew_root}/bin/perlbrew"
View
5 cookbooks/perlbrew/resources/run.rb
@@ -20,11 +20,6 @@
actions :run
-def initialize(*args)
- super
- @action = :run
-end
-
attribute :command, :name_attribute => true, :kind_of => String
attribute :perlbrew, :kind_of => String, :required => true
attribute :cwd, :kind_of => String
View
13 cookbooks/perlbrew/resources/service.rb
@@ -20,14 +20,15 @@
actions :create
-def initialize(*args)
- super
- @action = :create
-end
-
attribute :perlbrew, :kind_of => String, :required => true
attribute :command, :kind_of => String, :required => true
attribute :user, :kind_of => String, :default => "nobody"
attribute :group, :kind_of => String, :default => "nobody"
-attribute :cwd, :kind_of => String, :default "/"
+attribute :cwd, :kind_of => String, :default => "/"
attribute :environment, :kind_of => Hash, :default => {}
+
+def initialize(*args)
+ super
+ @action = :create
+end
+
View
2  cookbooks/perlbrew/templates/default/sv-perlbrew-service-log-run.erb
@@ -0,0 +1,2 @@
+#!/bin/sh
+exec svlogd -tt ./main
View
12 cookbooks/perlbrew/templates/default/sv-perlbrew-service-run.erb
@@ -1,6 +1,8 @@
#!/bin/bash
-source <%= @options[:perlbrew_root] %>/etc/bashrc
-cd <%= @options[:resource].cwd %>
-perlbrew use <%= @options[:resource].perlbrew %>
-exec chpst -u <%= @options[:resource].user %>:<%= @options[:resource].group %> <%= @options[:resource].command %>
-
+export PERLBREW_ROOT=<%= @options[:perlbrew_root] %>
+export PERLBREW_HOME=<%= @options[:perlbrew_root] %>
+source $PERLBREW_ROOT/etc/bashrc
+perlbrew use <%= @options[:perlbrew] %>
+svc_dir=$(pwd)
+cd <%= @options[:cwd] %>
+exec chpst -e $svc_dir/env -u<%= @options[:user] %>:<%= @options[:group] %> <%= @options[:command] %>
Please sign in to comment.
Something went wrong with that request. Please try again.