Skip to content
This repository has been archived by the owner on Dec 31, 2022. It is now read-only.

Commit

Permalink
fix: Moved extra env files creation, later in the stack (before_restart)
Browse files Browse the repository at this point in the history
Invoking figaro/dotenv files creation in configure phase, breaks the initial setup of the
application, since the `current` directory is not there yet. Moving it to the `before_restart`
hooks, solves that problem, since the application is properly deployed, and `current` symlink is
created.
  • Loading branch information
Igor Rzegocki committed Aug 29, 2016
1 parent 73ed40a commit 8a5223f
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 28 deletions.
2 changes: 1 addition & 1 deletion libraries/drivers_appserver_base.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ class Base < Drivers::Base
include Drivers::Dsl::Notifies
include Drivers::Dsl::Output

def configure(context)
def deploy_before_restart(context)
application_yml(context)
dot_env(context)
end
Expand Down
4 changes: 1 addition & 3 deletions spec/fixtures/node.rb
Original file line number Diff line number Diff line change
Expand Up @@ -71,9 +71,7 @@ def node(override = {})
},
appserver: {
adapter: 'unicorn',
worker_processes: 8,
application_yml: true,
dot_env: true
worker_processes: 8
},
webserver: {
adapter: 'nginx',
Expand Down
25 changes: 1 addition & 24 deletions spec/unit/recipes/configure_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
let(:chef_run) do
ChefSpec::SoloRunner.new(platform: 'ubuntu', version: '14.04') do |solo_node|
solo_node.set['deploy'] = node['deploy']
solo_node.set['defaults'] = { 'appserver' => node['defaults']['appserver'] }
solo_node.set['nginx'] = node['nginx']
end.converge(described_recipe)
end
Expand Down Expand Up @@ -61,35 +60,13 @@
)
end

it 'creates proper application.yml file' do
expect(chef_run)
.to render_file("/srv/www/#{aws_opsworks_app['shortname']}/shared/config/application.yml")
.with_content('ENV_VAR1: "test"')
expect(chef_run)
.to render_file("/srv/www/#{aws_opsworks_app['shortname']}/shared/config/application.yml")
.with_content('ENV_VAR2: "some data"')
expect(chef_run)
.to create_link("/srv/www/#{aws_opsworks_app['shortname']}/current/config/application.yml")
end

it 'creates proper dot_env file' do
expect(chef_run)
.to render_file("/srv/www/#{aws_opsworks_app['shortname']}/shared/dot_env")
.with_content('ENV_VAR1="test"')
expect(chef_run)
.to render_file("/srv/www/#{aws_opsworks_app['shortname']}/shared/dot_env")
.with_content('ENV_VAR2="some data"')
expect(chef_run)
.to create_link("/srv/www/#{aws_opsworks_app['shortname']}/current/.env")
end

it 'creates proper unicorn.conf file' do
expect(chef_run)
.to render_file("/srv/www/#{aws_opsworks_app['shortname']}/shared/config/unicorn.conf")
.with_content('ENV[\'ENV_VAR1\'] = "test"')
expect(chef_run)
.to render_file("/srv/www/#{aws_opsworks_app['shortname']}/shared/config/unicorn.conf")
.with_content('worker_processes 8')
.with_content('worker_processes 4')
expect(chef_run)
.to render_file("/srv/www/#{aws_opsworks_app['shortname']}/shared/config/unicorn.conf")
.with_content(':delay => 3')
Expand Down

0 comments on commit 8a5223f

Please sign in to comment.