Permalink
Browse files

added group and fcgi

  • Loading branch information...
1 parent ee21fc8 commit a1a0e3bc04a815431f6705603ba3b6ec8ccf5167 @gilles gilles committed with Nov 4, 2011
Showing with 281 additions and 0 deletions.
  1. +72 −0 providers/fcgi.rb
  2. +72 −0 providers/group.rb
  3. +59 −0 resources/fcgi.rb
  4. +30 −0 resources/group.rb
  5. +43 −0 templates/default/fcgi.conf.erb
  6. +5 −0 templates/default/group.conf.erb
View
@@ -0,0 +1,72 @@
+#
+# Author:: Noah Kantrowitz <noah@opscode.com>
+# Cookbook Name:: supervisor
+# Provider:: service
+#
+# Copyright:: 2011, Opscode, Inc <legal@opscode.com>
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+action :enable do
+ execute "supervisorctl update" do
+ action :nothing
+ user "root"
+ end
+
+ template "#{node['supervisor']['dir']}/#{new_resource.program_name}.conf" do
+ source "fcgi.conf.erb"
+ cookbook "supervisor"
+ owner "root"
+ group "root"
+ mode "644"
+ variables :prog => new_resource
+ notifies :run, resources(:execute => "supervisorctl update"), :immediately
+ end
+end
+
+action :disable do
+ execute "supervisorctl update" do
+ action :nothing
+ user "root"
+ end
+
+ file "#{node['supervisor']['dir']}/#{new_resource.program_name}.conf" do
+ action :delete
+ notifies :run, resources(:execute => "supervisorctl update"), :immediately
+ end
+end
+
+action :start do
+ execute "supervisorctl start #{new_resource.program_name}" do
+ user "root"
+ end
+end
+
+action :stop do
+ execute "supervisorctl stop #{new_resource.program_name}" do
+ user "root"
+ end
+end
+
+action :restart do
+ execute "supervisorctl restart #{new_resource.program_name}" do
+ user "root"
+ end
+end
+
+action :reload do
+ execute "supervisorctl restart #{new_resource.program_name}" do
+ user "root"
+ end
+end
View
@@ -0,0 +1,72 @@
+#
+# Author:: Noah Kantrowitz <noah@opscode.com>
+# Cookbook Name:: supervisor
+# Provider:: service
+#
+# Copyright:: 2011, Opscode, Inc <legal@opscode.com>
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+action :enable do
+ execute "supervisorctl update" do
+ action :nothing
+ user "root"
+ end
+
+ template "#{node['supervisor']['dir']}/#{new_resource.group_name}.conf" do
+ source "group.conf.erb"
+ cookbook "supervisor"
+ owner "root"
+ group "root"
+ mode "644"
+ variables :prog => new_resource
+ notifies :run, resources(:execute => "supervisorctl update"), :immediately
+ end
+end
+
+action :disable do
+ execute "supervisorctl update" do
+ action :nothing
+ user "root"
+ end
+
+ file "#{node['supervisor']['dir']}/#{new_resource.group_name}.conf" do
+ action :delete
+ notifies :run, resources(:execute => "supervisorctl update"), :immediately
+ end
+end
+
+action :start do
+ execute "supervisorctl start #{new_resource.group_name}" do
+ user "root"
+ end
+end
+
+action :stop do
+ execute "supervisorctl stop #{new_resource.group_name}" do
+ user "root"
+ end
+end
+
+action :restart do
+ execute "supervisorctl restart #{new_resource.group_name}" do
+ user "root"
+ end
+end
+
+action :reload do
+ execute "supervisorctl restart #{new_resource.group_name}" do
+ user "root"
+ end
+end
View
@@ -0,0 +1,59 @@
+#
+# Author:: Noah Kantrowitz <noah@opscode.com>
+# Cookbook Name:: supervisor
+# Resource:: service
+#
+# Copyright:: 2011, Opscode, Inc <legal@opscode.com>
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+actions :enable, :disable, :start, :stop, :restart, :reload
+
+def initialize(*args)
+ super
+ @action = [:enable, :start]
+end
+
+attribute :program_name, :kind_of => String, :name_attribute => true
+attribute :command, :kind_of => String
+attribute :process_name, :kind_of => String, :default => '%(program_name)s'
+attribute :numprocs, :kind_of => Integer, :default => 1
+attribute :numprocs_start, :kind_of => Integer, :default => 0
+attribute :priority, :kind_of => Integer, :default => 999
+attribute :autostart, :kind_of => [TrueClass, FalseClass], :default => true
+attribute :autorestart, :kind_of => [String, Symbol, TrueClass, FalseClass], :default => :unexpected
+attribute :startsecs, :kind_of => Integer, :default => 1
+attribute :startretries, :kind_of => Integer, :default => 3
+attribute :exitcodes, :kind_of => Array, :default => [0, 2]
+attribute :stopsignal, :kind_of => [String, Symbol], :default => :TERM
+attribute :stopwaitsecs, :kind_of => Integer, :default => 10
+attribute :user, :kind_of => [String, NilClass], :default => nil
+attribute :redirect_stderr, :kind_of => [TrueClass, FalseClass], :default => false
+attribute :stdout_logfile, :kind_of => String, :default => 'AUTO'
+attribute :stdout_logfile_maxbytes, :kind_of => String, :default => '50MB'
+attribute :stdout_logfile_backups, :kind_of => Integer, :default => 10
+attribute :stdout_capture_maxbytes, :kind_of => String, :default => '0'
+attribute :stdout_events_enabled, :kind_of => [TrueClass, FalseClass], :default => false
+attribute :stderr_logfile, :kind_of => String, :default => 'AUTO'
+attribute :stderr_logfile_maxbytes, :kind_of => String, :default => '50MB'
+attribute :stderr_logfile_backups, :kind_of => Integer, :default => 10
+attribute :stderr_capture_maxbytes, :kind_of => String, :default => '0'
+attribute :stderr_events_enabled, :kind_of => [TrueClass, FalseClass], :default => false
+attribute :environment, :kind_of => Hash, :default => {}
+attribute :directory, :kind_of => [String, NilClass], :default => nil
+attribute :umask, :kind_of => [NilClass, String], :default => nil
+attribute :serverurl, :kind_of => String, :default => 'AUTO'
+attribute :socket, :kind_of => String, :required => true
+attribute :socket_owner, :kind_of => String, :default => nil
+attribute :socket_mode, :kind_of => String, :required => '0700'
View
@@ -0,0 +1,30 @@
+#
+# Author:: Gilles Devaux <gilles@formspring.me>
+# Cookbook Name:: supervisor
+# Resource:: service
+#
+# Copyright:: 2011, Formspring.me
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+actions :enable, :disable, :start, :stop, :restart, :reload
+
+def initialize(*args)
+ super
+ @action = [:enable, :start]
+end
+
+attribute :group_name, :kind_of => String, :name_attribute => true
+attribute :programs, :kind_of => Array, :default => []
+attribute :priority, :kind_of => Integer
@@ -0,0 +1,43 @@
+[fcgi-program:<%= @prog.program_name %>]
+command=<%= @prog.command %>
+socket=<%= @prog.socket %>
+process_name=<%= @prog.process_name %>
+numprocs=<%= @prog.numprocs %>
+numprocs_start=<%= @prog.numprocs_start %>
+autostart=<%= @prog.autostart ? 'true' : 'false' %>
+autorestart=<%= @prog.autorestart.is_a?(String) ? @prog.autorestart : ( @prog.autorestart ? 'true' : 'false' ) %>
+startsecs=<%= @prog.startsecs %>
+startretries=<%= @prog.startretries %>
+exitcodes=<%= @prog.exitcodes.join(',') %>
+stopsignal=<%= @prog.stopsignal %>
+stopwaitsecs=<%= @prog.stopwaitsecs %>
+<% if @prog.user %>
+user=<%= @prog.user %>
+<% end %>
+redirect_stderr=<%= @prog.redirect_stderr ? 'true' : 'false' %>
+stdout_logfile=<%= @prog.stdout_logfile %>
+stdout_logfile_maxbytes=<%= @prog.stdout_logfile_maxbytes %>
+stdout_logfile_backups=<%= @prog.stdout_logfile_backups %>
+stdout_capture_maxbytes=<%= @prog.stdout_capture_maxbytes %>
+stdout_events_enabled=<%= @prog.stdout_events_enabled ? 'true' : 'false' %>
+stderr_logfile=<%= @prog.stderr_logfile %>
+stderr_logfile_maxbytes=<%= @prog.stderr_logfile_maxbytes %>
+stderr_logfile_backups=<%= @prog.stderr_logfile_backups %>
+stderr_capture_maxbytes=<%= @prog.stderr_capture_maxbytes %>
+stderr_events_enabled=<%= @prog.stderr_events_enabled ? 'true' : 'false' %>
+<% unless @prog.environment.empty? %>
+environment=<%= @prog.environment.map{|k,v| "#{k}=\"#{v}\""}.join(',') %>
+<% end %>
+<% if @prog.directory %>
+directory=<%= @prog.directory %>
+<% end %>
+<% if @prog.umask %>
+umask=<%= @prog.umask %>
+<% end %>
+serverurl=<%= @prog.serverurl %>
+<% if @prog.socket_owner %>
+socket_owner=<%= @prog.socket_owner %>
+<% end %>
+<% if @prog.socket_mode %>
+socket_mode=<%= @prog.socket_mode %>
+<% end %>
@@ -0,0 +1,5 @@
+[group:<%= @prog.group_name %>]
+programs=<%= @prog.programs.join(',') %>
+<% if @prog.priority %>
+priority=<%= @prog.priority %>
+<% end %>

0 comments on commit a1a0e3b

Please sign in to comment.