Skip to content

Commit 926f644

Browse files
author
Joshua Timberman
committed
Merge pull request poise#18 from needle-cookbooks/COOK-2337
COOK-2337: expose environment attribute on gunicorn and celery submodules
2 parents d560fa7 + e28a169 commit 926f644

4 files changed

Lines changed: 12 additions & 2 deletions

File tree

providers/celery.rb

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,9 +80,14 @@
8080
django_resource = new_resource.application.sub_resources.select{|res| res.type == :django}.first
8181
raise "No Django deployment resource found" unless django_resource
8282
command "#{::File.join(django_resource.virtualenv, "bin", "python")} manage.py #{cmd}"
83+
environment new_resource.environment
8384
else
8485
command cmd
85-
environment 'CELERY_CONFIG_MODULE' => new_resource.config
86+
if new_resource.environment
87+
environment new_resource.environment.merge({'CELERY_CONFIG_MODULE' => new_resource.config})
88+
else
89+
environment 'CELERY_CONFIG_MODULE' => new_resource.config
90+
end
8691
end
8792
directory ::File.join(new_resource.path, "current")
8893
autostart false

providers/gunicorn.rb

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
gunicorn_install "gunicorn-#{new_resource.application.name}" do
3333
virtualenv django_resource ? django_resource.virtualenv : new_resource.virtualenv
3434
end
35-
35+
3636
if !new_resource.restart_command
3737
new_resource.restart_command do
3838
run_context.resource_collection.find(:supervisor_service => new_resource.application.name).run_action(:restart)
@@ -72,6 +72,9 @@
7272

7373
supervisor_service new_resource.application.name do
7474
action :enable
75+
if new_resource.environment
76+
environment new_resource.environment
77+
end
7578
if new_resource.app_module == :django
7679
django_resource = new_resource.application.sub_resources.select{|res| res.type == :django}.first
7780
raise "No Django deployment resource found" unless django_resource

resources/celery.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
attribute :celerybeat, :kind_of => [TrueClass, FalseClass], :default => false
2828
attribute :celerycam, :kind_of => [TrueClass, FalseClass], :default => false
2929
attribute :camera_class, :kind_of => [String, NilClass], :default => nil
30+
attribute :environment, :kind_of => [Hash], :default => {}
3031

3132
def config_base
3233
config.split(/[\\\/]/).last

resources/gunicorn.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,3 +44,4 @@
4444
attribute :virtualenv, :kind_of => String, :default => nil
4545
attribute :packages, :kind_of => [Array, Hash], :default => []
4646
attribute :requirements, :kind_of => [NilClass, String, FalseClass], :default => nil
47+
attribute :environment, :kind_of => [Hash], :default => {}

0 commit comments

Comments
 (0)