Trying to deploy a rails app but having some issues


#1

Hey all I am trying to deploy a rails app. I was going to use the
application cookbook but decided to try and go at it myself. I have
gotten to the stage where it checkout the source code and handles the
submodules but the symlinking doesn’t seem to be working properly.
Specifically the log symlink. Instead of symlinking the log directory
it creates a log symlink inside of the log directory which would mean
the logs would have to be in RAILS_ROOT/log/log/production.log Is
this a bug in the deploy resource?

BTW…

What do you guys think about putting a deploy.rb someplace and
shelling out to cap deploy?

Here is the recipe so far

app_path = “#{app[:path]}/#{app[:environment]}”

%w(bundle cached-copy config log pids system).each do |dir|
directory app_path do
owner app[:user]
group app[:user]
mode "0755"
action :create
recursive true
end

end

%w(bundle cached-copy config log pids system).each do |dir|
directory “#{app_path}/shared/#{dir}” do
owner app[:user]
group app[:user]
mode "0755"
action :create
recursive true
end

end

#has other dependencies…
deploy app_path do
repo app[:repo]
revision app[:revision]
user app[:user]
enable_submodules true
migrate false
migration_command "bundle exec rake db:migrate"
environment “RAILS_ENV” => “production”, “OTHER_ENV” => "foo"
shallow_clone true
create_dirs_before_symlink %w{log config pids system tmp}
action :deploy # or :rollback
restart_command "touch tmp/restart.txt"
scm_provider Chef::Provider::Git # is the default, for svn:
Chef::Provider::Subversion
end


#2

Tim,

I have written a RoR application deployment cookbook. I would say writing your own is the best way to go.

Have you considered creating the log directory in the target application directory inside a shared folder and then symlinking that in to the actual deployment directory, that seemed to work out best. That way you can have the logs persist over deployments, and have the system use log management software to purge older logs or compress them etc…?

Thanks.


Sahil R Cooner

On Wednesday, January 4, 2012 at 7:15 PM, Tim Uckun wrote:

Hey all I am trying to deploy a rails app. I was going to use the
application cookbook but decided to try and go at it myself. I have
gotten to the stage where it checkout the source code and handles the
submodules but the symlinking doesn’t seem to be working properly.
Specifically the log symlink. Instead of symlinking the log directory
it creates a log symlink inside of the log directory which would mean
the logs would have to be in RAILS_ROOT/log/log/production.log Is
this a bug in the deploy resource?

BTW…

What do you guys think about putting a deploy.rb someplace and
shelling out to cap deploy?

Here is the recipe so far

app_path = “#{app[:path]}/#{app[:environment]}”

%w(bundle cached-copy config log pids system).each do |dir|
directory app_path do
owner app[:user]
group app[:user]
mode "0755"
action :create
recursive true
end

end

%w(bundle cached-copy config log pids system).each do |dir|
directory “#{app_path}/shared/#{dir}” do
owner app[:user]
group app[:user]
mode "0755"
action :create
recursive true
end

end

#has other dependencies…
deploy app_path do
repo app[:repo]
revision app[:revision]
user app[:user]
enable_submodules true
migrate false
migration_command "bundle exec rake db:migrate"
environment “RAILS_ENV” => “production”, “OTHER_ENV” => "foo"
shallow_clone true
create_dirs_before_symlink %w{log config pids system tmp}
action :deploy # or :rollback
restart_command "touch tmp/restart.txt"
scm_provider Chef::Provider::Git # is the default, for svn:
Chef::Provider::Subversion
end


#3

I have written a RoR application deployment cookbook. I would say writing
your own is the best way to go.

I have started going down this route. I think what I am going to do is
to integrate caphub with chef solo at this point. I have set up a
caphub structure, I plan on checking it out of git (or putting it
inside the kitchen as a submodule) and then shelling out to it. This
allows me to deploy both manually and automatically via chef

Have you considered creating the log directory in the target application
directory inside a shared folder and then symlinking that in to the actual
deployment directory, that seemed to work out best. That way you can have
the logs persist over deployments, and have the system use log management
software to purge older logs or compress them etc…?

This is what the deploy resource is attempting to do but not doing quite right.