Permalink
Browse files

various fixes to get perlbrew_service working

  • Loading branch information...
1 parent 10a4ba0 commit 437004594da977cdf26716d9d901554272dcec58 @xdg xdg committed Jan 20, 2012
@@ -22,24 +22,32 @@
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 = {
'PERLBREW_ROOT' => node['perlbrew']['perlbrew_root'],
'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
@@ -23,6 +23,8 @@
package p
end
+include_recipe "runit"
+
perlbrew_root = node['perlbrew']['perlbrew_root']
perlbrew_bin = "#{perlbrew_root}/bin/perlbrew"
@@ -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
@@ -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
+
@@ -0,0 +1,2 @@
+#!/bin/sh
+exec svlogd -tt ./main
@@ -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] %>

0 comments on commit 4370045

Please sign in to comment.