Am using mina for deployment. Am having gem 'mina-unicorn', :require => false
in the Gemfile(I tried replacing the above line with gem 'unicorn'
) and then I did bundle install
.
When I run mina deploy --verbose I see bundler: failed to load command: unicorn (/home/deployer/.rbenv/versions/2.1.2/bin/unicorn)
Gem::LoadError: unicorn is not part of the bundle. Add it to Gemfile.
Looks like some problem with the path of the gem files not being set properly.
Here is the console output
-----> Loading environment
$ source ~/.bashrc
-----> Loading rbenv
$ export RBENV_ROOT="$HOME/.rbenv"
$ export PATH="$HOME/.rbenv/bin:$PATH"
$ eval "$(rbenv init -)"
-----> Creating a temporary build path
$ touch "deploy.lock"
$ mkdir -p "$build_path"
$ cd "$build_path"
-----> Quiet sidekiq (stop accepting new work)
Skip quiet command (no pid file found)
-----> Fetching new git commits
$ (cd "/home/deployer/salesforcecasts/scm" && git fetch "https://kkteja@bitbucket.org/kkteja/salesforce_casts.git" "master:master" --force)
-----> Using git branch 'master'
$ git clone "/home/deployer/salesforcecasts/scm" . --recursive --branch "master"
Cloning into '.'...
done.
perl: warning: Setting locale failed.
perl: warning: Please check that your locale settings:
LANGUAGE = (unset),
LC_ALL = (unset),
LC_CTYPE = "UTF-8",
LANG = "en_US.UTF-8"
are supported and installed on your system.
perl: warning: Falling back to the standard locale ("C").
perl: warning: Setting locale failed.
perl: warning: Please check that your locale settings:
LANGUAGE = (unset),
LC_ALL = (unset),
LC_CTYPE = "UTF-8",
LANG = "en_US.UTF-8"
are supported and installed on your system.
perl: warning: Falling back to the standard locale ("C").
-----> Using this git commit
$ git rev-parse HEAD > .mina_git_revision
$ git --no-pager log --format='%aN (%h):%n> %s' -n 1
Krishna Teja (ec42bcc):
> added about me
$ rm -rf .git
-----> Symlinking shared paths
$ mkdir -p "./config"
$ mkdir -p "."
$ rm -rf "./config/database.yml"
$ ln -s "/home/deployer/salesforcecasts/shared/config/database.yml" "./config/database.yml"
$ rm -rf "./config/secrets.yml"
$ ln -s "/home/deployer/salesforcecasts/shared/config/secrets.yml" "./config/secrets.yml"
$ rm -rf "./log"
$ ln -s "/home/deployer/salesforcecasts/shared/log" "./log"
-----> Installing gem dependencies using Bundler
$ mkdir -p "/home/deployer/salesforcecasts/shared/bundle"
$ mkdir -p "./vendor"
$ ln -s "/home/deployer/salesforcecasts/shared/bundle" "./vendor/bundle"
$ bundle install --without development:test --path "./vendor/bundle" --deployment
Using rake 11.1.2
Using i18n 0.7.0
Using json 1.8.3
Using minitest 5.8.4
Using thread_safe 0.3.5
Using builder 3.2.2
Using erubis 2.7.0
Using mini_portile2 2.0.0
Using rack 1.6.4
Using mime-types-data 3.2016.0221
Using arel 6.0.3
Using bcrypt 3.1.11
Using coffee-script-source 1.10.0
Using execjs 2.6.0
Using thor 0.19.1
Using concurrent-ruby 1.0.2
Using orm_adapter 0.5.0
Using ionicons-rails 2.0.0
Using multi_json 1.12.0
Using pg 0.18.4
Using bundler 1.12.5
Using rails_serve_static_assets 0.0.5
Using rails_stdout_logging 0.0.5
Using sass 3.4.22
Using tilt 2.0.2
Using rdoc 4.2.2
Using tzinfo 1.2.2
Using nokogiri 1.6.7.2
Using rack-test 0.6.3
Using warden 1.2.6
Using mime-types 3.0
Using coffee-script 2.4.1
Using uglifier 3.0.0
Using sprockets 3.6.0
Using rails_12factor 0.0.3
Using sdoc 0.4.1
Using activesupport 4.2.5.1
Using loofah 2.0.3
Using mail 2.6.4
Using rails-deprecated_sanitizer 1.0.3
Using globalid 0.3.6
Using activemerchant 1.58.0
Using activemodel 4.2.5.1
Using jbuilder 2.4.1
Using rails-html-sanitizer 1.0.3
Using rails-dom-testing 1.0.7
Using activejob 4.2.5.1
Using activerecord 4.2.5.1
Using actionview 4.2.5.1
Using actionpack 4.2.5.1
Using actionmailer 4.2.5.1
Using railties 4.2.5.1
Using sprockets-rails 3.0.4
Using coffee-rails 4.1.1
Using responders 2.1.1
Using jquery-rails 4.1.1
Using tinymce-rails 4.3.12
Using rails 4.2.5.1
Using sass-rails 5.0.4
Using turbolinks 2.5.3
Using devise 3.5.6
Bundle complete! 18 Gemfile dependencies, 61 gems now installed.
Gems in the groups development and test were not installed.
Bundled gems are installed into ./vendor/bundle.
-----> DB migrations unchanged; skipping DB migration
-----> Skipping asset precompilation
$ mkdir -p "/home/deployer/salesforcecasts/$build_path/public/assets"
$ cp -R "/home/deployer/salesforcecasts/current/public/assets/." "/home/deployer/salesforcecasts/$build_path/public/assets"
-----> Deploy finished
-----> Building
-----> Moving build to releases/8
$ mv "$build_path" "$release_path"
$ cd "$release_path"
-----> Build finished
-----> Launching
-----> Updating the current symlink
$ ln -nfs "$release_path" "current"
-----> Launching
$ cd "current"
-----> Starting Unicorn...
bundler: failed to load command: unicorn (/home/deployer/.rbenv/versions/2.1.2/bin/unicorn)
Gem::LoadError: unicorn is not part of the bundle. Add it to Gemfile.
/home/deployer/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/bundler-1.12.5/lib/bundler/rubygems_integration.rb:322:in `block in replace_gem'
/home/deployer/.rbenv/versions/2.1.2/bin/unicorn:22:in `<top (required)>'
-----> Done. Deployed v8
Connection to 139.59.9.195 closed.
Elapsed time: 9.00 seconds
When I run gem which unicorn
I see this
/home/deployer/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/unicorn-5.1.0/lib/unicorn.rb
This is what gem env
gives
RubyGems Environment:
- RUBYGEMS VERSION: 2.2.2
- RUBY VERSION: 2.1.2 (2014-05-08 patchlevel 95) [x86_64-linux]
- INSTALLATION DIRECTORY: /home/deployer/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0
- RUBY EXECUTABLE: /home/deployer/.rbenv/versions/2.1.2/bin/ruby
- EXECUTABLE DIRECTORY: /home/deployer/.rbenv/versions/2.1.2/bin
- SPEC CACHE DIRECTORY: /home/deployer/.gem/specs
- RUBYGEMS PLATFORMS:
- ruby
- x86_64-linux
- GEM PATHS:
- /home/deployer/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0
- /home/deployer/.gem/ruby/2.1.0
- GEM CONFIGURATION:
- :update_sources => true
- :verbose => true
- :backtrace => false
- :bulk_threshold => 1000
- REMOTE SOURCES:
- https://rubygems.org/
- SHELL PATH:
- /home/deployer/.rbenv/versions/2.1.2/bin
- /home/deployer/.rbenv/libexec
- /home/deployer/.rbenv/plugins/ruby-build/bin
- /home/deployer/.rbenv/shims
- /home/deployer/.rbenv/bin
- /usr/local/sbin
- /usr/local/bin
- /usr/sbin
- /usr/bin
- /sbin
- /bin
- /usr/games
- /usr/local/games
- /lib/ruby/gems/2.1.0/bin
- /home/deployer/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/bin
This is the config/deploy.rb
file
require 'mina/bundler'
require 'mina/rails'
require 'mina/git'
require 'mina/rbenv' # for rbenv support. (http://rbenv.org)
# require 'mina/rvm' # for rvm support. (http://rvm.io)
require 'mina_sidekiq/tasks'
require 'mina/unicorn'
# Basic settings:
# domain - The hostname to SSH to.
# deploy_to - Path to deploy into.
# repository - Git repo to clone from. (needed by mina/git)
# branch - Branch name to deploy. (needed by mina/git)
set :domain, '139.59.9.195'
set :deploy_to, '/home/deployer/salesforcecasts'
set :repository, 'https://kkteja@bitbucket.org/kkteja/salesforce_casts.git'
set :branch, 'master'
set :user, 'deployer'
set :forward_agent, true
set :port, '22'
set :unicorn_pid, "#{deploy_to}/shared/pids/unicorn.pid"
set :term_mode, nil
# For system-wide RVM install.
# set :rvm_path, '/usr/local/rvm/bin/rvm'
# Manually create these paths in shared/ (eg: shared/config/database.yml) in your server.
# They will be linked in the 'deploy:link_shared_paths' step.
set :shared_paths, ['config/database.yml', 'config/secrets.yml', 'log']
# Optional settings:
# set :user, 'foobar' # Username in the server to SSH to.
# set :port, '30000' # SSH port number.
# set :forward_agent, true # SSH forward_agent.
# This task is the environment that is loaded for most commands, such as
# `mina deploy` or `mina rake`.
task :environment do
# If you're using rbenv, use this to load the rbenv environment.
# Be sure to commit your .ruby-version or .rbenv-version to your repository.
queue %{
echo "-----> Loading environment"
#{echo_cmd %[source ~/.bashrc]}
}
invoke :'rbenv:load'
# For those using RVM, use this to load an RVM version@gemset.
# invoke :'rvm:use[ruby-1.9.3-p125@default]'
end
# Put any custom mkdir's in here for when `mina setup` is ran.
# For Rails apps, we'll make some of the shared paths that are shared between
# all releases.
task :setup => :environment do
queue! %[mkdir -p "#{deploy_to}/#{shared_path}/log"]
queue! %[chmod g+rx,u+rwx "#{deploy_to}/#{shared_path}/log"]
queue! %[mkdir -p "#{deploy_to}/#{shared_path}/config"]
queue! %[chmod g+rx,u+rwx "#{deploy_to}/#{shared_path}/config"]
queue! %[touch "#{deploy_to}/#{shared_path}/config/database.yml"]
queue! %[touch "#{deploy_to}/#{shared_path}/config/secrets.yml"]
queue %[echo "-----> Be sure to edit '#{deploy_to}/#{shared_path}/config/database.yml' and 'secrets.yml'."]
# sidekiq needs a place to store its pid file and log file
queue! %[mkdir -p "#{deploy_to}/shared/pids/"]
queue! %[chmod g+rx,u+rwx "#{deploy_to}/shared/pids"]
if repository
repo_host = repository.split(%r{@|://}).last.split(%r{:|/}).first
repo_port = /:([0-9]+)/.match(repository) && /:([0-9]+)/.match(repository)[1] || '22'
queue %[
if ! ssh-keygen -H -F #{repo_host} &>/dev/null; then
ssh-keyscan -t rsa -p #{repo_port} -H #{repo_host} >> ~/.ssh/known_hosts
fi
]
end
end
desc "Deploys the current version to the server."
task :deploy => :environment do
to :before_hook do
# Put things to run locally before ssh
end
deploy do
# Put things that will set up an empty directory into a fully set-up
# instance of your project.
invoke :'sidekiq:quiet'
invoke :'git:clone'
invoke :'deploy:link_shared_paths'
invoke :'bundle:install'
invoke :'rails:db_migrate'
invoke :'rails:assets_precompile'
#invoke :'deploy:cleanup'
to :launch do
# queue "mkdir -p #{deploy_to}/#{current_path}/tmp/"
#queue "touch #{deploy_to}/#{current_path}/tmp/restart.txt"
#invoke :'sidekiq:restart'
invoke :'unicorn:restart'
end
end
end
This is config/unicorn.rb
# set path to application
app_dir = File.expand_path("../..", __FILE__)
shared_dir = "#{app_dir}/shared"
working_directory app_dir
# Set unicorn options
worker_processes 2
preload_app true
timeout 30
# Set up socket location
listen "#{shared_dir}/sockets/unicorn.sock", :backlog => 64
# Logging
stderr_path "#{shared_dir}/log/unicorn.stderr.log"
stdout_path "#{shared_dir}/log/unicorn.stdout.log"
# Set master PID location
pid "#{shared_dir}/pids/unicorn.pid"
before_fork do |server, worker|
defined?(ActiveRecord::Base) and ActiveRecord::Base.connection.disconnect!
old_pid = "#{server.config[:pid]}.oldbin"
if File.exists?(old_pid) && server.pid != old_pid
begin
sig = (worker.nr + 1) >= server.worker_processes ? :QUIT : :TTOU
Process.kill(sig, File.read(old_pid).to_i)
rescue Errno::ENOENT, Errno::ESRCH
# someone else did our job for us
end
end
end
after_fork do |server, worker|
defined?(ActiveRecord::Base) and ActiveRecord::Base.establish_connection
end
before_exec do |server|
ENV['BUNDLE_GEMFILE'] = "#{app_dir}/Gemfile"
end
Any help will be much appreciated
Aucun commentaire:
Enregistrer un commentaire