Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

first attempt at perlbrew_service

  • Loading branch information...
commit 10a4ba010272799bf243c0e9103cde042f8c28d7 1 parent 2dc49c9
David Golden dagolden authored
46 cookbooks/perlbrew/providers/service.rb
... ... @@ -0,0 +1,46 @@
  1 +#
  2 +# Author:: David A. Golden
  3 +# Cookbook Name:: perlbrew
  4 +# Provider:: perlbrew_service
  5 +#
  6 +# Copyright:: 2012, David A. Golden <dagolden@cpan.org>
  7 +#
  8 +# Licensed under the Apache License, Version 2.0 (the "License");
  9 +# you may not use this file except in compliance with the License.
  10 +# You may obtain a copy of the License at
  11 +#
  12 +# http://www.apache.org/licenses/LICENSE-2.0
  13 +#
  14 +# Unless required by applicable law or agreed to in writing, software
  15 +# distributed under the License is distributed on an "AS IS" BASIS,
  16 +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  17 +# See the License for the specific language governing permissions and
  18 +# limitations under the License.
  19 +#
  20 +
  21 +require 'chef/mixin/shell_out'
  22 +require 'chef/mixin/language'
  23 +include Chef::Mixin::ShellOut
  24 +
  25 +include_recipe "runit"
  26 +
  27 +# XXX must be a fully qualified 'perl-5.X.Y@libname' style name
  28 +action :create do
  29 + perlbrew_env = {
  30 + 'PERLBREW_ROOT' => node['perlbrew']['perlbrew_root'],
  31 + 'PERLBREW_HOME' => node['perlbrew']['perlbrew_root']
  32 + }
  33 +
  34 + runit_service new_resource.name do
  35 + template_name 'perlbrew-service'
  36 + cookbook 'perlbrew'
  37 + options(
  38 + :perlbrew_root => node['perlbrew']['perlbrew_root'],
  39 + :resource => new_resource
  40 + )
  41 + env new_resource.environment.merge(perlbrew_env)
  42 + run_restart false
  43 + end
  44 +end
  45 +
  46 +# :enable :disable :nothing :start :stop :restart :reload}
33 cookbooks/perlbrew/resources/service.rb
... ... @@ -0,0 +1,33 @@
  1 +#
  2 +# Author:: David A. Golden
  3 +# Cookbook Name:: perlbrew
  4 +# Resource:: perlbrew_service
  5 +#
  6 +# Copyright:: 2012, David A. Golden <dagolden@cpan.org>
  7 +#
  8 +# Licensed under the Apache License, Version 2.0 (the "License");
  9 +# you may not use this file except in compliance with the License.
  10 +# You may obtain a copy of the License at
  11 +#
  12 +# http://www.apache.org/licenses/LICENSE-2.0
  13 +#
  14 +# Unless required by applicable law or agreed to in writing, software
  15 +# distributed under the License is distributed on an "AS IS" BASIS,
  16 +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  17 +# See the License for the specific language governing permissions and
  18 +# limitations under the License.
  19 +#
  20 +
  21 +actions :create
  22 +
  23 +def initialize(*args)
  24 + super
  25 + @action = :create
  26 +end
  27 +
  28 +attribute :perlbrew, :kind_of => String, :required => true
  29 +attribute :command, :kind_of => String, :required => true
  30 +attribute :user, :kind_of => String, :default => "nobody"
  31 +attribute :group, :kind_of => String, :default => "nobody"
  32 +attribute :cwd, :kind_of => String, :default "/"
  33 +attribute :environment, :kind_of => Hash, :default => {}
6 cookbooks/perlbrew/templates/default/sv-perlbrew-service-run.erb
... ... @@ -0,0 +1,6 @@
  1 +#!/bin/bash
  2 +source <%= @options[:perlbrew_root] %>/etc/bashrc
  3 +cd <%= @options[:resource].cwd %>
  4 +perlbrew use <%= @options[:resource].perlbrew %>
  5 +exec chpst -u <%= @options[:resource].user %>:<%= @options[:resource].group %> <%= @options[:resource].command %>
  6 +

0 comments on commit 10a4ba0

Please sign in to comment.
Something went wrong with that request. Please try again.