Mina部署不能一直工作

时间:2016-07-20 16:25:23

标签: ruby-on-rails unicorn mina

我这个问题已经持续了3个月左右。当我进行mina部署时,不会发生任何错误,它会显示sidekiq等的启动/停止。但有时最新的代码实际上并未部署到生产服务器。使用相同的代码我也没有在登台环境中遇到过这个问题,这实在令人困惑。

要解决此问题,我必须手动终止unicorn pid,然后重新部署,每次都有效。

我对这些内容并不十分熟悉,主要是从文章和文章中复制而来。那么,您是否在代码中看到可能导致问题的任何内容?我应该停止独角兽然后重新启动它而不是仅仅重新启动它吗?我的想法是,我可能会错过请求。

desc "Deploys the current version to the server."
task :deploy => :environment do
  deploy do

  # stop accepting new workers
  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
    invoke :'sidekiq:restart'
    invoke :'unicorn:restart'
  end
end

无论如何,我可以在部署内部的某些时间输出语句,还是创建日志?

- 编辑:(添加痕迹) -

这是一个过往的痕迹。是否有某种类型的错误应该出现在我可以查找的失败跟踪上?它不会一直失败,但我每次都可以运行跟踪以尝试捕获失败的跟踪。

** Invoke deploy (first_time)
** Invoke environment (first_time)
** Execute environment
** Invoke rbenv:load (first_time)
** Execute rbenv:load
** Execute deploy
** Invoke sidekiq:quiet (first_time)
** Invoke environment 
** Execute sidekiq:quiet
** Invoke git:clone (first_time)
** Execute git:clone
** Invoke deploy:link_shared_paths (first_time)
** Execute deploy:link_shared_paths
** Invoke bundle:install (first_time)
** Execute bundle:install
** Invoke rails:db_migrate (first_time)
** Execute rails:db_migrate
** Invoke rails:assets_precompile (first_time)
** Execute rails:assets_precompile
** Invoke deploy:cleanup (first_time)
** Execute deploy:cleanup
** Invoke sidekiq:restart (first_time)
** Execute sidekiq:restart
** Invoke sidekiq:stop (first_time)
** Invoke environment 
** Execute sidekiq:stop
** Invoke sidekiq:start (first_time)
** Invoke environment 
** Execute sidekiq:start
** Invoke unicorn:restart (first_time)
** Invoke environment 
** Execute unicorn:restart

-----> 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)
       $ RAILS_ENV="staging" bundle exec sidekiqctl quiet /home/deploy/PATH       $ RAILS_ENV="staging" bundle exec sidekiqctl quiet /home/deploy/PATHNAME//shared/pids/sidekiq.pid

-----> Fetching new git commits
       $ (cd "/home/deploy/PATHNAME//scm" && git fetch "git@github.com:k       $ (cd "/home/deploy/PATHNAME//scm" && git fetch "git@github.com:kenmazaika/PATHNAME.git" "master:master" --force)

-----> Using git branch 'master'
       $ git clone "/home/deploy/PATHNAME//scm" . --recursive --branch "       $ git clone "/home/deploy/PATHNAME//scm" . --recursive --branch "master"
       Cloning into '.'...
       done.

-----> Using this git commit

       $ git --no-pager log --format='%aN (%h):%n> %s' -n 1
       MYNAME (a0ba681):
       > Merge pull request #2040 from repo/issue2039
       $ rm -rf .git


-----> Symlinking shared paths
       $ mkdir -p "./config"
       $ mkdir -p "."
       $ rm -rf "./config/database.yml"
       $ ln -s "/home/deploy/PATHNAME//shared/config/database.yml" "./co       $ ln -s "/home/deploy/PATHNAME//shared/config/database.yml" "./config/database.yml"
       $ rm -rf "./log"
       $ ln -s "/home/deploy/PATHNAME//shared/log" "./log"
       $ rm -rf "./config/secrets.yml"
       $ ln -s "/home/deploy/PATHNAME//shared/config/secrets.yml" "./con       $ ln -s "/home/deploy/PATHNAME//shared/config/secrets.yml" "./config/secrets.yml"

-----> Installing gem dependencies using Bundler
       $ mkdir -p "/home/deploy/PATHNAME//shared/bundle"
       $ mkdir -p "./vendor"
       $ ln -s "/home/deploy/PATHNAME//shared/bundle" "./vendor/bundle"
       $ bundle install --without development:test --path "./vendor/bundle" --de       $ bundle install --without development:test --path "./vendor/bundle" --deployment

       ### USING A BUNCH OF GEMS ###

-----> DB migrations unchanged; skipping DB migration

-----> Skipping asset precompilation
       $ cp -R "/home/deploy/PATHNAME//current/public/assets" "./public"

-----> Cleaning up old releases (keeping 5)
       $ cd "/home/deploy/PATHNAME//releases" || exit 15
       $ count=`ls -1d [0-9]* | sort -rn | wc -l`
       $ remove=$((count > 5 ? count - 5 : 0))
       $ ls -1d [0-9]* | sort -rn | tail -n $remove | xargs rm -rf {}

-----> Build finished

-----> Moving build to releases/301
       $ mv "$build_path" "$release_path"

-----> Updating the current symlink
       $ ln -nfs "$release_path" "current"

-----> Launching
       $ cd "$release_path"

-----> Stop sidekiq
       $ RAILS_ENV="staging" bundle exec sidekiqctl stop /home/deploy/PATHl       $ RAILS_ENV="staging" bundle exec sidekiqctl stop /home/deploy/PATHNAME//shared/pids/sidekiq.pid 10
       Sidekiq shut down gracefully.

-----> Start sidekiq
       $ nohup bundle exec sidekiq -e staging -C /home/deploy/PATHNAME//current/config/sidekiq.yml -i 0 -P /home/deploy/PATHNAME//shared/pids/si       $ nohup bundle exec sidekiq -e staging -C /home/deploy/PATHNAME//current/config/sidekiq.yml -i 0 -P /home/deploy/PATHNAME//shared/pids/sidekiq.pid >> /home/deploy/PATHNAME//current/log/sidekiq.log 2>&1 &

-----> Starting Unicorn...

0 个答案:

没有答案