bloomberg/collectd-cookbook

View on GitHub
templates/default/upstart.erb

Summary

Maintainability
Test Coverage
# <%= @name %> generated by poise-service for <%= @new_resource.to_s %>

description "<%= @name %>"

start on runlevel [2345]
stop on runlevel [!2345]

expect fork
respawn
respawn limit 10 5
umask 022
chdir <%= @directory %>
<%- @environment.each do |key, val| -%>
env <%= key %>="<%= val %>"
<%- end -%>
<%- if @upstart_features[:setuid] -%>
setuid <%= @user %>
<%- end -%>
<%- if @upstart_features[:kill_signal] -%>
kill signal <%= @stop_signal %>
<%- end -%>
<%- if @upstart_features[:reload_signal] -%>
reload signal <%= @reload_signal %>
<%- end -%>

<%- if @upstart_features[:setuid] -%>
exec <%= @command %>
<%- else -%>
exec /opt/chef/embedded/bin/ruby -e 'Process.uid = "<%= @user %>"; ENV["HOME"] = Dir.home("<%= @user %>") rescue nil; exec(*<%= Shellwords.split(@command).inspect %>)'
<%- end -%>
<%- if !@upstart_features[:kill_signal] && @stop_signal != 'TERM' -%>
pre-stop script
  PID=`initctl status <%= @name %> | sed 's/^.*process \([0-9]*\)$/\1/'`
  if [ -n "$PID" ]; then
    kill -<%= @stop_signal %> "$PID"
  fi
end script
<%- end -%>