Added capistrano

This commit is contained in:
Tom Naessens 2014-11-25 10:00:55 +01:00
parent 73e24e2b55
commit 9a97cc94e1
6 changed files with 112 additions and 0 deletions

11
Capfile Normal file
View file

@ -0,0 +1,11 @@
# Load DSL and Setup Up Stages
require 'capistrano/setup'
# Includes default deployment tasks
require 'capistrano/deploy'
require 'capistrano/rails'
require 'capistrano/rvm'
# Loads custom tasks from `lib/capistrano/tasks' if you have any defined.
Dir.glob('lib/capistrano/tasks/*.cap').each { |r| import r }

View file

@ -35,6 +35,14 @@ gem 'spring', group: :development
# Use Capistrano for deployment
# gem 'capistrano-rails', group: :development
# Deployment
gem 'capistrano', '~> 3.1'
gem 'capistrano-rails', '~> 1.1'
gem 'capistrano-rvm'
group :production do
gem 'mysql2' # Database
end
# Use debugger
# gem 'debugger', group: [:development, :test]

View file

@ -38,6 +38,19 @@ GEM
columnize (~> 0.8)
debugger-linecache (~> 1.2)
slop (~> 3.6)
capistrano (3.2.1)
i18n
rake (>= 10.0.0)
sshkit (~> 1.3)
capistrano-bundler (1.1.3)
capistrano (~> 3.1)
sshkit (~> 1.2)
capistrano-rails (1.1.2)
capistrano (~> 3.1)
capistrano-bundler (~> 1.1)
capistrano-rvm (0.1.2)
capistrano (~> 3.0)
sshkit (~> 1.2)
coffee-rails (4.0.1)
coffee-script (>= 2.2.0)
railties (>= 4.0.0, < 5.0)
@ -45,6 +58,7 @@ GEM
coffee-script-source
execjs
coffee-script-source (1.8.0)
colorize (0.7.3)
columnize (0.8.9)
debugger-linecache (1.2.0)
erubis (2.7.0)
@ -63,6 +77,10 @@ GEM
mime-types (2.4.3)
minitest (5.4.3)
multi_json (1.10.1)
mysql2 (0.3.17)
net-scp (1.2.1)
net-ssh (>= 2.6.5)
net-ssh (2.9.1)
rack (1.5.2)
rack-test (0.6.2)
rack (>= 1.0)
@ -105,6 +123,10 @@ GEM
activesupport (>= 3.0)
sprockets (>= 2.8, < 4.0)
sqlite3 (1.3.10)
sshkit (1.5.1)
colorize
net-scp (>= 1.1.2)
net-ssh (>= 2.8.0)
thor (0.19.1)
thread_safe (0.3.4)
tilt (1.4.1)
@ -125,9 +147,13 @@ DEPENDENCIES
bootstrap-sass (= 3.2.0.0)
bootstrap-will_paginate (= 0.0.10)
byebug
capistrano (~> 3.1)
capistrano-rails (~> 1.1)
capistrano-rvm
coffee-rails (~> 4.0.0)
jbuilder (~> 2.0)
jquery-rails
mysql2
rails (= 4.1.7)
sass-rails (~> 4.0.3)
sdoc (~> 0.4.0)

51
config/deploy.rb Normal file
View file

@ -0,0 +1,51 @@
# config valid only for Capistrano 3.1
# lock '3.1.0'
set :application, 'Tab'
set :repo_url, 'git@github.com:ZeusWPI/Tab.git'
set :branch, 'master'
set :deploy_to, '/home/tab/production'
# Default branch is :master
# ask :branch, proc { `git rev-parse --abbrev-ref HEAD`.chomp }
# Default deploy_to directory is /var/www/my_app
# set :deploy_to, '/var/www/my_app'
# Default value for :scm is :git
# set :scm, :git
# Default value for :format is :pretty
# set :format, :pretty
# Default value for :log_level is :debug
set :log_level, :debug
# Default value for :pty is false
# set :pty, true
# Default value for :linked_files is []
# set :linked_files, %w{config/database.yml}
# Default value for linked_dirs is []
set :linked_dirs, %w{bin log tmp/pids tmp/cache tmp/sockets vendor/bundle public/system}
# Default value for default_env is {}
# set :default_env, { path: "/opt/ruby/bin:$PATH" }
# Default value for keep_releases is 5
# set :keep_releases, 5
namespace :passenger do
desc "Restart Application"
task :restart do
on roles(:app) do
with rails_env: fetch(:rails_env) do
execute "touch #{current_path}/tmp/restart.txt"
end
end
end
end
after :deploy, "passenger:restart"

View file

@ -0,0 +1,8 @@
server 'zeus.ugent.be', user: 'tab', roles: %w{web app db},
ssh_options: {
forward_agent: true,
auth_methods: ['publickey'],
port: 2222
}
set :rails_env, 'production'

View file

@ -0,0 +1,8 @@
namespace :logs do
desc "tail rails logs"
task :tail do
on roles(:app) do
execute "tail -f #{shared_path}/log/#{fetch(:rails_env)}.log"
end
end
end