Skip to content

Commit

Permalink
possibly working capistrano deployment
Browse files Browse the repository at this point in the history
  • Loading branch information
ubergesundheit committed Jun 1, 2014
1 parent 5a0258d commit ddd4428
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 23 deletions.
4 changes: 4 additions & 0 deletions Capfile
Original file line number Diff line number Diff line change
Expand Up @@ -21,5 +21,9 @@ require 'capistrano/deploy'
# require 'capistrano/rails/assets'
# require 'capistrano/rails/migrations'

require 'capistrano/rbenv'
require 'capistrano/bundler'
require 'capistrano/rails'

# Loads custom tasks from `lib/capistrano/tasks' if you have any defined.
Dir.glob('lib/capistrano/tasks/*.rake').each { |r| import r }
34 changes: 15 additions & 19 deletions config/deploy.rb
Original file line number Diff line number Diff line change
@@ -1,18 +1,21 @@
# config valid only for Capistrano 3.1
lock '3.2.1'

set :application, 'my_app_name'
set :repo_url, 'git@example.com:me/my_repo.git'
set :application, 'dialog_map'
set :repo_url, 'git@github.com:ubergesundheit/masterthesis.git'

# Default branch is :master
# ask :branch, proc { `git rev-parse --abbrev-ref HEAD`.chomp }.call
set :branch, 'chef'

# Default deploy_to directory is /var/www/my_app
# set :deploy_to, '/var/www/my_app'
set :deploy_to, '/home/apps/dialog-map'

# Default value for :scm is :git
# set :scm, :git
set :bundle_flags, "--deployment"
set :bundle_without, "test development deploy"

set :rbenv_type, :system
set :rbenv_ruby, '2.1.2'
set :rbenv_custom_path, '/opt/rbenv'

set :linked_files, %w{.rbenv-vars}
# Default value for :format is :pretty
# set :format, :pretty

Expand All @@ -23,7 +26,7 @@
# set :pty, true

# Default value for :linked_files is []
set :linked_files, %w{.rbenv-vars}


# Default value for linked_dirs is []
# set :linked_dirs, %w{bin log tmp/pids tmp/cache tmp/sockets vendor/bundle public/system}
Expand All @@ -39,20 +42,13 @@
desc 'Restart application'
task :restart do
on roles(:app), in: :sequence, wait: 5 do
# Your restart mechanism here, for example:
# execute :touch, release_path.join('tmp/restart.txt')
execute :touch, release_path.join('tmp/restart.txt')
end
end

after :publishing, :restart

after :restart, :clear_cache do
on roles(:web), in: :groups, limit: 3, wait: 10 do
# Here we can do anything such as:
# within release_path do
# execute :rake, 'cache:clear'
# end
end
end
before :starting, :chown_apps_dir_to_deploy
before :restart, :chown_apps_dir_to_apps

end
8 changes: 4 additions & 4 deletions config/deploy/production.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@
# is considered to be the first unless any hosts have the primary
# property set. Don't declare `role :all`, it's a meta role.

role :app, %w{deploy@example.com}
role :web, %w{deploy@example.com}
role :db, %w{deploy@example.com}
role :app, %w{deploy@localhost:2222}
role :db, %w{deploy@localhost:2222}
role :web, %w{deploy@localhost:2222}


# Extended Server Syntax
Expand All @@ -15,7 +15,7 @@
# server list. The second argument is a, or duck-types, Hash and is
# used to set extended properties on the server.

server 'example.com', user: 'deploy', roles: %w{web app}, my_property: :my_value
# server 'example.com', user: 'deploy', roles: %w{web app}, my_property: :my_value


# Custom SSH Options
Expand Down
15 changes: 15 additions & 0 deletions lib/capistrano/tasks/chown_apps_dir.rake
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
desc "Chown the apps dir to apps user"
task :chown_apps_dir_to_apps do
on roles(:all) do
sudo :chown, "-R apps:apps #{deploy_to}"
end
end

desc "Chown the apps dir to deploy user"
task :chown_apps_dir_to_deploy do
on roles(:all) do
if test "[ -d #{deploy_to} ]"
sudo :chown, "-R deploy:deploy #{deploy_to}"
end
end
end

0 comments on commit ddd4428

Please sign in to comment.