Created
July 1, 2013 09:26
-
-
Save olkeene/5899522 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| # NOTE: capistrano's 'current' dir can not exist when running script first time, | |
| # so need to place this script to diff place, for ex, /home/ubuntu/texenergo | |
| # 1. make sure that ruby + capistrano are installed on server | |
| # 2. run "capify ." which will create: | |
| # ./Capfile | |
| # and | |
| # ./config/deploy.rb | |
| # replace the deploy file with this script | |
| # 3. for local deploy current user must have ability to ssh to same host: | |
| # 3.1. add data from ~/.ssh/id_rsa.pub to ~/.ssh/authorized_keys | |
| # 4. Onboot run: | |
| # crontab -e | |
| # @reboot cd /home/ubuntu/texenergo && cap deploy:setup && cap deploy | |
| server '127.0.0.1', :web, :db, :primary => true | |
| role :app, '' | |
| set :app_env, "production" | |
| set :application, "Texenergo" | |
| set :deploy_to, "/home/ubuntu/texenergo" | |
| set :keep_releases, 5 | |
| set :rails_env, "production" | |
| set :deploy_via, :remote_cache | |
| set :scm, :git | |
| set :git_enable_submodules, false | |
| set :repository, "git@github.com:marzhaev/texenergo.git" | |
| set :branch, "master" | |
| set :rvm_autolibs_flag, "read-only" | |
| set :rvm_ruby_string, :local | |
| set :unicorn_env, "production" | |
| set :user, "ubuntu" | |
| set :use_sudo, false | |
| #before 'deploy:setup', 'rvm:install_rvm' | |
| #before 'deploy:setup', 'rvm:install_ruby' | |
| #before 'deploy:setup', 'rvm:create_gemset' | |
| after "deploy:setup", "deploy:ensure_dirs" | |
| after "deploy:update", "deploy:cleanup" | |
| require 'bundler/capistrano' | |
| #require "rvm/capistrano" | |
| #load 'deploy/assets' | |
| namespace :deploy do | |
| desc "Just to make sure that neccessary folders are in place" | |
| task :ensure_dirs do | |
| run "mkdir -p #{shared_path}/pids" | |
| run "mkdir -p #{shared_path}/log" | |
| end | |
| desc "Zero-downtime restart of Unicorn" | |
| task :restart, :except => { :no_release => true } do | |
| run "#{sudo} kill -s USR2 `cat #{shared_path}/pids/unicorn.pid`" | |
| end | |
| desc "Start unicorn" | |
| task :start, :except => { :no_release => true } do | |
| run "cd #{current_path} ; bundle exec unicorn_rails -c config/unicorn.rb -D -E #{rails_env}" | |
| end | |
| desc "Stop unicorn" | |
| task :stop, :except => { :no_release => true } do | |
| #run "#{sudo} kill -s QUIT `cat #{shared_path}/pids/unicorn.pid`" | |
| run "kill -s QUIT `cat #{shared_path}/pids/unicorn.pid`" | |
| end | |
| end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment