gem added to gemfile and bundle install is run but still am seeing Gem::LoadError: unicorn is not part of the bundle. Add it to Gemfile
gem added to gemfile and bundle install is run but still am seeing Gem::LoadError: unicorn is not part of the bundle. Add it to Gemfile
我正在使用 mina 进行部署。我在 Gemfile 中有 gem 'mina-unicorn', :require => false
(我尝试用 gem 'unicorn'
替换上面的行)然后我做了 bundle install
。
当我 运行 mina deploy --verbose 我看到 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.
似乎 gem 文件的路径设置不正确。
这是控制台输出
-----> 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
当我 运行 gem which unicorn
我看到这个
/home/deployer/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/unicorn-5.1.0/lib/unicorn.rb
这就是 gem env
给
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
这是 config/deploy.rb
文件
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
这是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
这是 Gemfile
source 'https://rubygems.org'
# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
gem 'rails', '4.2.5.1'
# Use postgresql as the database for Active Record
gem 'pg', '~> 0.15'
# Use SCSS for stylesheets
gem 'sass-rails', '~> 5.0'
# Use Uglifier as compressor for JavaScript assets
gem 'uglifier', '>= 1.3.0'
# Use CoffeeScript for .coffee assets and views
gem 'coffee-rails', '~> 4.1.0'
# See https://github.com/rails/execjs#readme for more supported runtimes
# gem 'therubyracer', platforms: :ruby
# Use jquery as the JavaScript library
gem 'jquery-rails'
# Turbolinks makes following links in your web application faster. Read more: https://github.com/rails/turbolinks
gem 'turbolinks'
# Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder
gem 'jbuilder', '~> 2.0'
# bundle exec rake doc:rails generates the API under doc/api.
gem 'sdoc', '~> 0.4.0', group: :doc
#gem 'sidekiq'
gem 'mina'
gem 'mina-sidekiq', :require => false
gem 'mina-unicorn', :require => false
gem 'devise'
gem 'ionicons-rails'
gem 'activemerchant'
gem 'tinymce-rails'
# Use ActiveModel has_secure_password
# gem 'bcrypt', '~> 3.1.7'
# Use Unicorn as the app server
#gem 'unicorn'
# Use Capistrano for deployment
# gem 'capistrano-rails', group: :development
group :development, :test do
# Call 'byebug' anywhere in the code to stop execution and get a debugger console
gem 'byebug'
gem 'faker'
end
gem 'rails_12factor'
group :development do
# Access an IRB console on exception pages or by using <%= console %> in views
gem 'web-console', '~> 2.0'
# Spring speeds up development by keeping your application running in the background. Read more: https://github.com/rails/spring
gem 'spring'
end
更新
$ bundle exec sidekiq -d -e production -C /home/deployer/salesforcecasts/current/config/sidekiq.yml -c 25 -i 0 -P /home/deployer/salesforcecasts/shared/pids/sidekiq.pid -L /home/deployer/salesforcecasts/current/log/sidekiq.log
-----> Starting Unicorn...
bundler: failed to load command: unicorn (/home/deployer/salesforcecasts/current/vendor/bundle/ruby/2.1.0/bin/unicorn)
ArgumentError: directory for pid=/home/deployer/salesforcecasts/current/shared/pids/unicorn.pid not writable
/home/deployer/salesforcecasts/shared/bundle/ruby/2.1.0/gems/unicorn-5.1.0/lib/unicorn/configurator.rb:88:in `block in reload'
/home/deployer/salesforcecasts/shared/bundle/ruby/2.1.0/gems/unicorn-5.1.0/lib/unicorn/configurator.rb:84:in `each'
/home/deployer/salesforcecasts/shared/bundle/ruby/2.1.0/gems/unicorn-5.1.0/lib/unicorn/configurator.rb:84:in `reload'
/home/deployer/salesforcecasts/shared/bundle/ruby/2.1.0/gems/unicorn-5.1.0/lib/unicorn/configurator.rb:65:in `initialize'
/home/deployer/salesforcecasts/shared/bundle/ruby/2.1.0/gems/unicorn-5.1.0/lib/unicorn/http_server.rb:76:in `new'
/home/deployer/salesforcecasts/shared/bundle/ruby/2.1.0/gems/unicorn-5.1.0/lib/unicorn/http_server.rb:76:in `initialize'
/home/deployer/salesforcecasts/current/vendor/bundle/ruby/2.1.0/gems/unicorn-5.1.0/bin/unicorn:126:in `new'
/home/deployer/salesforcecasts/current/vendor/bundle/ruby/2.1.0/gems/unicorn-5.1.0/bin/unicorn:126:in `<top (required)>'
/home/deployer/salesforcecasts/current/vendor/bundle/ruby/2.1.0/bin/unicorn:23:in `load'
/home/deployer/salesforcecasts/current/vendor/bundle/ruby/2.1.0/bin/unicorn:23:in `<top (required)>'
master failed to start, check stderr log for details
-----> Done. Deployed v6
任何帮助将不胜感激
mina-unicorn
根据其 gemspec 没有 unicorn
依赖项,您必须在 Gemfile
中明确添加它
gem 'mina-unicorn', :require => false
gem 'unicorn'
此外,根据您的 bundle install
输出,您可以看出未安装 unicorn。
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
更新:
mina 做的是:
从您在config/deploy.rb
中指定的远程存储库中获取代码库,这是https://kkteja@bitbucket.org/kkteja/salesforce_casts.git, and from the file https://bitbucket.org/kkteja/salesforce_casts/src/ec42bcc304fb581f5b7a0a61b9c073f66b0dffac/Gemfile?fileviewer=file-view-default您可以看到,unicorn
不是。
虽然你在 Gemfile 中添加了它,但如果你不将更改提交到 bitbucket,它不会影响 mina 部署。
实际上,您不必手动将存储库克隆到 Digital Ocean,所有部署工作都可以在您自己的机器上完成。
更新:
确保您的 pid 文件和目录对于您的 deployer
用户是可写的,就像日志中所说的那样。
我正在使用 mina 进行部署。我在 Gemfile 中有 gem 'mina-unicorn', :require => false
(我尝试用 gem 'unicorn'
替换上面的行)然后我做了 bundle install
。
当我 运行 mina deploy --verbose 我看到 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.
似乎 gem 文件的路径设置不正确。
这是控制台输出
-----> 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
当我 运行 gem which unicorn
我看到这个
/home/deployer/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/unicorn-5.1.0/lib/unicorn.rb
这就是 gem env
给
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
这是 config/deploy.rb
文件
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
这是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
这是 Gemfile
source 'https://rubygems.org'
# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
gem 'rails', '4.2.5.1'
# Use postgresql as the database for Active Record
gem 'pg', '~> 0.15'
# Use SCSS for stylesheets
gem 'sass-rails', '~> 5.0'
# Use Uglifier as compressor for JavaScript assets
gem 'uglifier', '>= 1.3.0'
# Use CoffeeScript for .coffee assets and views
gem 'coffee-rails', '~> 4.1.0'
# See https://github.com/rails/execjs#readme for more supported runtimes
# gem 'therubyracer', platforms: :ruby
# Use jquery as the JavaScript library
gem 'jquery-rails'
# Turbolinks makes following links in your web application faster. Read more: https://github.com/rails/turbolinks
gem 'turbolinks'
# Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder
gem 'jbuilder', '~> 2.0'
# bundle exec rake doc:rails generates the API under doc/api.
gem 'sdoc', '~> 0.4.0', group: :doc
#gem 'sidekiq'
gem 'mina'
gem 'mina-sidekiq', :require => false
gem 'mina-unicorn', :require => false
gem 'devise'
gem 'ionicons-rails'
gem 'activemerchant'
gem 'tinymce-rails'
# Use ActiveModel has_secure_password
# gem 'bcrypt', '~> 3.1.7'
# Use Unicorn as the app server
#gem 'unicorn'
# Use Capistrano for deployment
# gem 'capistrano-rails', group: :development
group :development, :test do
# Call 'byebug' anywhere in the code to stop execution and get a debugger console
gem 'byebug'
gem 'faker'
end
gem 'rails_12factor'
group :development do
# Access an IRB console on exception pages or by using <%= console %> in views
gem 'web-console', '~> 2.0'
# Spring speeds up development by keeping your application running in the background. Read more: https://github.com/rails/spring
gem 'spring'
end
更新
$ bundle exec sidekiq -d -e production -C /home/deployer/salesforcecasts/current/config/sidekiq.yml -c 25 -i 0 -P /home/deployer/salesforcecasts/shared/pids/sidekiq.pid -L /home/deployer/salesforcecasts/current/log/sidekiq.log
-----> Starting Unicorn...
bundler: failed to load command: unicorn (/home/deployer/salesforcecasts/current/vendor/bundle/ruby/2.1.0/bin/unicorn)
ArgumentError: directory for pid=/home/deployer/salesforcecasts/current/shared/pids/unicorn.pid not writable
/home/deployer/salesforcecasts/shared/bundle/ruby/2.1.0/gems/unicorn-5.1.0/lib/unicorn/configurator.rb:88:in `block in reload'
/home/deployer/salesforcecasts/shared/bundle/ruby/2.1.0/gems/unicorn-5.1.0/lib/unicorn/configurator.rb:84:in `each'
/home/deployer/salesforcecasts/shared/bundle/ruby/2.1.0/gems/unicorn-5.1.0/lib/unicorn/configurator.rb:84:in `reload'
/home/deployer/salesforcecasts/shared/bundle/ruby/2.1.0/gems/unicorn-5.1.0/lib/unicorn/configurator.rb:65:in `initialize'
/home/deployer/salesforcecasts/shared/bundle/ruby/2.1.0/gems/unicorn-5.1.0/lib/unicorn/http_server.rb:76:in `new'
/home/deployer/salesforcecasts/shared/bundle/ruby/2.1.0/gems/unicorn-5.1.0/lib/unicorn/http_server.rb:76:in `initialize'
/home/deployer/salesforcecasts/current/vendor/bundle/ruby/2.1.0/gems/unicorn-5.1.0/bin/unicorn:126:in `new'
/home/deployer/salesforcecasts/current/vendor/bundle/ruby/2.1.0/gems/unicorn-5.1.0/bin/unicorn:126:in `<top (required)>'
/home/deployer/salesforcecasts/current/vendor/bundle/ruby/2.1.0/bin/unicorn:23:in `load'
/home/deployer/salesforcecasts/current/vendor/bundle/ruby/2.1.0/bin/unicorn:23:in `<top (required)>'
master failed to start, check stderr log for details
-----> Done. Deployed v6
任何帮助将不胜感激
mina-unicorn
根据其 gemspec 没有 unicorn
依赖项,您必须在 Gemfile
gem 'mina-unicorn', :require => false
gem 'unicorn'
此外,根据您的 bundle install
输出,您可以看出未安装 unicorn。
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
更新:
mina 做的是:
从您在config/deploy.rb
中指定的远程存储库中获取代码库,这是https://kkteja@bitbucket.org/kkteja/salesforce_casts.git, and from the file https://bitbucket.org/kkteja/salesforce_casts/src/ec42bcc304fb581f5b7a0a61b9c073f66b0dffac/Gemfile?fileviewer=file-view-default您可以看到,unicorn
不是。
虽然你在 Gemfile 中添加了它,但如果你不将更改提交到 bitbucket,它不会影响 mina 部署。
实际上,您不必手动将存储库克隆到 Digital Ocean,所有部署工作都可以在您自己的机器上完成。
更新:
确保您的 pid 文件和目录对于您的 deployer
用户是可写的,就像日志中所说的那样。