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

Commit

Permalink
fix(appserver): moved env files creation to before_symlink phase
Browse files Browse the repository at this point in the history
  • Loading branch information
ajgon committed Jun 8, 2018
1 parent 9af3651 commit abc4a17
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 13 deletions.
18 changes: 9 additions & 9 deletions libraries/drivers_appserver_base.rb
Expand Up @@ -13,7 +13,7 @@ def configure
add_appserver_service_context
end

def deploy_before_restart
def before_deploy
setup_application_yml
setup_dot_env
end
Expand Down Expand Up @@ -96,31 +96,31 @@ def add_appserver_service_context

def setup_application_yml
return unless raw_out[:application_yml]
node.default['deploy'][app['shortname']]['global']['symlinks']['config/application.yml'] =
'config/application.yml'
node.default['deploy'][app['shortname']]['global']['symlink_before_migrate']['config/application.yml'] =
'config/application.yml'
env_config(source_file: 'config/application.yml', destination_file: 'config/application.yml')
end

def setup_dot_env
return unless raw_out[:dot_env]
env_config(source_file: 'dot_env', destination_file: '.env')
node.default['deploy'][app['shortname']]['global']['symlinks']['dot_env'] = '.env'
node.default['deploy'][app['shortname']]['global']['symlink_before_migrate']['dot_env'] = '.env'
env_config(source_file: 'dot_env', destination_file: 'dot_env')
end

# rubocop:disable Metrics/MethodLength
def env_config(options = { source_file: nil, destination_file: nil })
deploy_to = deploy_dir(app)
env = environment

context.template File.join(deploy_to, 'shared', options[:source_file]) do
context.template File.join(deploy_to, 'shared', options[:destination_file]) do
owner node['deployer']['user']
group www_group
source "#{File.basename(options[:source_file])}.erb"
variables environment: env
end

context.link File.join(deploy_to, 'current', options[:destination_file]) do
to File.join(deploy_to, 'shared', options[:source_file])
end
end
# rubocop:enable Metrics/MethodLength

def environment
framework = Drivers::Framework::Factory.build(context, app, options)
Expand Down
8 changes: 4 additions & 4 deletions test/integration/all_options/serverspec/all_options_spec.rb
Expand Up @@ -193,13 +193,13 @@

context 'framework' do
describe command('ls -1 /srv/www/dummy_project/current/public/assets/application-*.css*') do
its(:stdout) { should_not match(/application-[0-9a-f]{64}.css/) }
its(:stdout) { should_not match(/application-[0-9a-f]{64}.css.gz/) }
its(:stdout) { should_not match(/application-.*\.css/) }
its(:stdout) { should_not match(/application-.*\.css\.gz/) }
end

describe command('ls -1 /srv/www/dummy_project/current/public/test/application-*.css*') do
its(:stdout) { should_not match(/application-[0-9a-f]{64}.css/) }
its(:stdout) { should_not match(/application-[0-9a-f]{64}.css.gz/) }
its(:stdout) { should_not match(/application-.*\.css/) }
its(:stdout) { should_not match(/application-.*\.css\.gz/) }
end

describe file('/srv/www/dummy_project/current/config/application.rb') do
Expand Down

0 comments on commit abc4a17

Please sign in to comment.