Last active
December 18, 2015 23:29
-
-
Save workmaster2n/5862353 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
deployer@arcsite:~/apps/arcsite/current$ bundle show paperclip | |
/home/deployer/.rvm/gems/ruby-1.9.3-p392@arcsite_mysql/gems/paperclip-3.4.2 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require "bundler/capistrano" | |
require "rvm/capistrano" | |
set :application, "arcsite" | |
set :repository, "git@github.com:PeritusSolutions/arcsite_mysql.git" | |
set :branch, "master" | |
set :user, "deployer" | |
set :deploy_to, "/home/#{user}/apps/#{application}" | |
set :deploy_via, :remote_cache | |
set :use_sudo, false | |
#rvm | |
set :rvm_ruby_string, :local | |
set :rvm_autolibs_flag, :enable | |
set :rvm_install_with_sudo, true | |
set :bundle_flags, '--system' | |
before 'deploy:setup', 'rvm:install_rvm' # install RVM | |
before 'deploy:setup', 'rvm:install_ruby' # install Ruby and create gemset | |
default_run_options[:pty] = true | |
ssh_options[:forward_agent] = true | |
set :scm, :git # You can set :scm explicitly or Capistrano will make an intelligent guess based on known version control directory names | |
# Or: `accurev`, `bzr`, `cvs`, `darcs`, `git`, `mercurial`, `perforce`, `subversion` or `none` | |
#server "192.168.0.30", :web, :app, :db, primary: true | |
server "198.199.105.200", :web, :app, :db, primary: true | |
#role :web, "your web-server here" # Your HTTP server, Apache/etc | |
#role :app, "your app-server here" # This may be the same as your `Web` server | |
#role :db, "your primary db-server here", :primary => true # This is where Rails migrations will run | |
#role :db, "your slave db-server here" | |
# if you want to clean up old releases on each deploy uncomment this: | |
after "deploy:restart", "deploy:cleanup" | |
# if you're still using the script/reaper helper you will need | |
# these http://github.com/rails/irs_process_scripts | |
# If you are using Passenger mod_rails uncomment this: | |
# namespace :deploy do | |
# task :start do ; end | |
# task :stop do ; end | |
# task :restart, :roles => :app, :except => { :no_release => true } do | |
# run "#{try_sudo} touch #{File.join(current_path,'tmp','restart.txt')}" | |
# end | |
# end | |
namespace :deploy do | |
%w[start stop restart].each do |command| | |
desc "#{command} unicorn server" | |
task command, roles: :app, except: {no_release: true} do | |
run "/etc/init.d/unicorn_#{application} #{command}" | |
end | |
end | |
task :setup_config, roles: :app do | |
sudo "ln -nfs #{current_path}/config/nginx.conf /etc/nginx/sites-enabled/#{application}" | |
sudo "ln -nfs #{current_path}/config/unicorn_init.sh /etc/init.d/unicorn_#{application}" | |
run "mkdir -p #{shared_path}/config" | |
put File.read("config/database.example.yml"), "#{shared_path}/config/database.yml" | |
puts "Now edit the config files in #{shared_path}." | |
end | |
after "deploy:setup", "deploy:setup_config" | |
task :symlink_config, roles: :app do | |
run "ln -nfs #{shared_path}/config/database.yml #{release_path}/config/database.yml" | |
end | |
after "deploy:finalize_update", "deploy:symlink_config" | |
desc "Make sure local git is in sync with remote." | |
task :check_revision, roles: :web do | |
unless `git rev-parse HEAD` == `git rev-parse origin/master` | |
puts "WARNING: HEAD is not the same as origin/master" | |
puts "Run `git push` to sync changes." | |
exit | |
end | |
end | |
before "deploy", "deploy:check_revision" | |
#precompile assets only when needed | |
namespace :assets do | |
task :precompile, :roles => :web, :except => { :no_release => true } do | |
from = source.next_revision(current_revision) | |
if capture("cd #{latest_release} && #{source.local.log(from)} vendor/assets/ app/assets/ | wc -l").to_i > 0 | |
run %Q{cd #{latest_release} && #{rake} RAILS_ENV=#{rails_env} #{asset_env} assets:precompile} | |
else | |
logger.info "Skipping asset pre-compilation because there were no asset changes" | |
end | |
end | |
end | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Tylers-MacBook-Pro:arcsite_mysql tyler$ cap deploy:migrations | |
* 2013-06-25 16:02:46 executing `deploy:migrations' | |
* 2013-06-25 16:02:46 executing `deploy:update_code' | |
updating the cached checkout on all servers | |
executing locally: "git ls-remote git@github.com:PeritusSolutions/arcsite_mysql.git master" | |
command finished in 1669ms | |
* executing "if [ -d /home/deployer/apps/arcsite/shared/cached-copy ]; then cd /home/deployer/apps/arcsite/shared/cached-copy && git fetch -q origin && git fetch --tags -q origin && git reset -q --hard e9a02ca057f822c8709ecb790177c78db6af8021 && git clean -q -d -x -f; else git clone -q -b master git@github.com:PeritusSolutions/arcsite_mysql.git /home/deployer/apps/arcsite/shared/cached-copy && cd /home/deployer/apps/arcsite/shared/cached-copy && git checkout -q -b deploy e9a02ca057f822c8709ecb790177c78db6af8021; fi" | |
servers: ["198.199.105.200"] | |
[198.199.105.200] executing command | |
command finished in 4356ms | |
copying the cached version to /home/deployer/apps/arcsite/releases/20130625210253 | |
* executing "cp -RPp /home/deployer/apps/arcsite/shared/cached-copy /home/deployer/apps/arcsite/releases/20130625210253 && (echo e9a02ca057f822c8709ecb790177c78db6af8021 > /home/deployer/apps/arcsite/releases/20130625210253/REVISION)" | |
servers: ["198.199.105.200"] | |
[198.199.105.200] executing command | |
command finished in 751ms | |
* 2013-06-25 16:02:53 executing `deploy:finalize_update' | |
triggering before callbacks for `deploy:finalize_update' | |
* 2013-06-25 16:02:53 executing `deploy:assets:symlink' | |
* executing "rm -rf /home/deployer/apps/arcsite/releases/20130625210253/public/assets && mkdir -p /home/deployer/apps/arcsite/releases/20130625210253/public && mkdir -p /home/deployer/apps/arcsite/shared/assets && ln -s /home/deployer/apps/arcsite/shared/assets /home/deployer/apps/arcsite/releases/20130625210253/public/assets" | |
servers: ["198.199.105.200"] | |
[198.199.105.200] executing command | |
command finished in 593ms | |
* 2013-06-25 16:02:54 executing `bundle:install' | |
* executing "cd /home/deployer/apps/arcsite/releases/20130625210253 && bundle install --gemfile /home/deployer/apps/arcsite/releases/20130625210253/Gemfile --path /home/deployer/apps/arcsite/shared/bundle --system --without development test" | |
servers: ["198.199.105.200"] | |
[198.199.105.200] executing command | |
** [out :: 198.199.105.200] You have specified both a path to install your gems to, | |
** [out :: 198.199.105.200] | |
** [out :: 198.199.105.200] as well as --system. Please choose. | |
** [out :: 198.199.105.200] | |
command finished in 990ms | |
failed: "rvm_path=$HOME/.rvm/ $HOME/.rvm/bin/rvm-shell 'ruby-1.9.3-p392@arcsite_mysql' -c 'cd /home/deployer/apps/arcsite/releases/20130625210253 && bundle install --gemfile /home/deployer/apps/arcsite/releases/20130625210253/Gemfile --path /home/deployer/apps/arcsite/shared/bundle --system --without development test'" on 198.199.105.200 | |
Tylers-MacBook-Pro:arcsite_mysql tyler$ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
E, [2013-06-25T21:15:45.960566 #341] ERROR -- : uninitialized constant Paperclip (NameError) | |
/home/deployer/apps/arcsite/releases/20130625211233/config/initializers/paperclip_custom_interpolator.rb:1:in `<top (required)>' | |
/home/deployer/apps/arcsite/shared/bundle/ruby/1.9.1/gems/railties-3.2.13/lib/rails/engine.rb:588:in `block (2 levels) in <class:Engine>' | |
/home/deployer/apps/arcsite/shared/bundle/ruby/1.9.1/gems/railties-3.2.13/lib/rails/engine.rb:587:in `each' | |
/home/deployer/apps/arcsite/shared/bundle/ruby/1.9.1/gems/railties-3.2.13/lib/rails/engine.rb:587:in `block in <class:Engine>' | |
/home/deployer/apps/arcsite/shared/bundle/ruby/1.9.1/gems/railties-3.2.13/lib/rails/initializable.rb:30:in `instance_exec' | |
/home/deployer/apps/arcsite/shared/bundle/ruby/1.9.1/gems/railties-3.2.13/lib/rails/initializable.rb:30:in `run' | |
/home/deployer/apps/arcsite/shared/bundle/ruby/1.9.1/gems/railties-3.2.13/lib/rails/initializable.rb:55:in `block in run_initializers' | |
/home/deployer/apps/arcsite/shared/bundle/ruby/1.9.1/gems/railties-3.2.13/lib/rails/initializable.rb:54:in `each' | |
/home/deployer/apps/arcsite/shared/bundle/ruby/1.9.1/gems/railties-3.2.13/lib/rails/initializable.rb:54:in `run_initializers' | |
/home/deployer/apps/arcsite/shared/bundle/ruby/1.9.1/gems/railties-3.2.13/lib/rails/application.rb:136:in `initialize!' | |
/home/deployer/apps/arcsite/shared/bundle/ruby/1.9.1/gems/railties-3.2.13/lib/rails/railtie/configurable.rb:30:in `method_missing' | |
/home/deployer/apps/arcsite/releases/20130625211233/config/environment.rb:5:in `<top (required)>' | |
config.ru:4:in `require' | |
config.ru:4:in `block in <main>' | |
/home/deployer/apps/arcsite/shared/bundle/ruby/1.9.1/gems/rack-1.4.5/lib/rack/builder.rb:51:in `instance_eval' | |
/home/deployer/apps/arcsite/shared/bundle/ruby/1.9.1/gems/rack-1.4.5/lib/rack/builder.rb:51:in `initialize' | |
config.ru:1:in `new' | |
config.ru:1:in `<main>' | |
/home/deployer/apps/arcsite/shared/bundle/ruby/1.9.1/gems/unicorn-4.6.2/lib/unicorn.rb:44:in `eval' | |
/home/deployer/apps/arcsite/shared/bundle/ruby/1.9.1/gems/unicorn-4.6.2/lib/unicorn.rb:44:in `block in builder' | |
/home/deployer/apps/arcsite/shared/bundle/ruby/1.9.1/gems/unicorn-4.6.2/lib/unicorn/http_server.rb:722:in `call' | |
/home/deployer/apps/arcsite/shared/bundle/ruby/1.9.1/gems/unicorn-4.6.2/lib/unicorn/http_server.rb:722:in `build_app!' | |
/home/deployer/apps/arcsite/shared/bundle/ruby/1.9.1/gems/unicorn-4.6.2/lib/unicorn/http_server.rb:595:in `init_worker_process' | |
/home/deployer/apps/arcsite/shared/bundle/ruby/1.9.1/gems/unicorn-4.6.2/lib/unicorn/http_server.rb:615:in `worker_loop' | |
/home/deployer/apps/arcsite/shared/bundle/ruby/1.9.1/gems/unicorn-4.6.2/lib/unicorn/http_server.rb:500:in `spawn_missing_workers' | |
/home/deployer/apps/arcsite/shared/bundle/ruby/1.9.1/gems/unicorn-4.6.2/lib/unicorn/http_server.rb:511:in `maintain_worker_count' | |
/home/deployer/apps/arcsite/shared/bundle/ruby/1.9.1/gems/unicorn-4.6.2/lib/unicorn/http_server.rb:277:in `join' | |
/home/deployer/apps/arcsite/shared/bundle/ruby/1.9.1/gems/unicorn-4.6.2/bin/unicorn:126:in `<top (required)>' | |
/home/deployer/apps/arcsite/shared/bundle/ruby/1.9.1/bin/unicorn:23:in `load' | |
/home/deployer/apps/arcsite/shared/bundle/ruby/1.9.1/bin/unicorn:23:in `<main>' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Bundle edge Rails instead: | |
# gem 'rails', :git => 'git://github.com/rails/rails.git' | |
gem 'pg' | |
gem 'rgeo' | |
gem 'rgeo-shapefile' | |
gem 'activerecord-postgis-adapter' | |
gem 'paperclip' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
upstream unicorn { | |
server unix:/tmp/unicorn.arcsite.sock fail_timeout=0; | |
} | |
server { | |
listen 80 default deferred; | |
# server_name example.com; | |
root /home/deployer/apps/arcsite/current/public; | |
location ^~ /assets/ { | |
gzip_static on; | |
expires max; | |
add_header Cache-Control public; | |
} | |
try_files $uri/index.html $uri @unicorn; | |
location @unicorn { | |
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; | |
proxy_set_header Host $http_host; | |
proxy_redirect off; | |
proxy_pass http://unicorn; | |
} | |
error_page 500 502 503 504 /500.html; | |
client_max_body_size 4G; | |
keepalive_timeout 10; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Paperclip.interpolates :zone do |attachment, style| | |
attachment.instance.zone_id | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
http://stackoverflow.com/questions/17306285/paperclip-in-production-with-unicorn-uninitialized-constant-paperclip-nameerro |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
root = "/home/deployer/apps/arcsite/current" | |
working_directory root | |
pid "#{root}/tmp/pids/unicorn.pid" | |
stderr_path "#{root}/log/unicorn.log" | |
stdout_path "#{root}/log/unicorn.log" | |
listen "/tmp/unicorn.arcsite.sock" | |
worker_processes 2 | |
timeout 30 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
set -e | |
# Feel free to change any of the following variables for your app: | |
TIMEOUT=${TIMEOUT-60} | |
APP_ROOT=/home/deployer/apps/arcsite/current | |
PID=$APP_ROOT/tmp/pids/unicorn.pid | |
CMD="cd $APP_ROOT; bundle exec unicorn -D -c $APP_ROOT/config/unicorn.rb -E production" | |
AS_USER=deployer | |
set -u | |
OLD_PIN="$PID.oldbin" | |
sig () { | |
test -s "$PID" && kill -$1 `cat $PID` | |
} | |
oldsig () { | |
test -s $OLD_PIN && kill -$1 `cat $OLD_PIN` | |
} | |
run () { | |
if [ "$(id -un)" = "$AS_USER" ]; then | |
eval $1 | |
else | |
su -c "$1" - $AS_USER | |
fi | |
} | |
case "$1" in | |
start) | |
sig 0 && echo >&2 "Already running" && exit 0 | |
run "$CMD" | |
;; | |
stop) | |
sig QUIT && exit 0 | |
echo >&2 "Not running" | |
;; | |
force-stop) | |
sig TERM && exit 0 | |
echo >&2 "Not running" | |
;; | |
restart|reload) | |
sig HUP && echo reloaded OK && exit 0 | |
echo >&2 "Couldn't reload, starting '$CMD' instead" | |
run "$CMD" | |
;; | |
upgrade) | |
if sig USR2 && sleep 2 && sig 0 && oldsig QUIT | |
then | |
n=$TIMEOUT | |
while test -s $OLD_PIN && test $n -ge 0 | |
do | |
printf '.' && sleep 1 && n=$(( $n - 1 )) | |
done | |
echo | |
if test $n -lt 0 && test -s $OLD_PIN | |
then | |
echo >&2 "$OLD_PIN still exists after $TIMEOUT seconds" | |
exit 1 | |
fi | |
exit 0 | |
fi | |
echo >&2 "Couldn't upgrade, starting '$CMD' instead" | |
run "$CMD" | |
;; | |
reopen-logs) | |
sig USR1 | |
;; | |
*) | |
echo >&2 "Usage: $0 <start|stop|restart|upgrade|force-stop|reopen-logs>" | |
exit 1 | |
;; | |
esac |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment