sidekiq没有开始使用mina部署rails 4 app。

时间:2015-06-09 04:12:26

标签: sidekiq ruby-on-rails-4.2

我有一个使用sidekiq的rails 4.2应用程序。我正在使用mina进行部署。我的Gemfile包含' sidekiq'和' mina-sidekiq'。

我的部署脚本为

require 'mina_sidekiq/tasks'                                                                                                                              
require 'mina/bundler'
require 'mina/rails'
require 'mina/git'
require 'mina/rvm'    # for rvm support. (http://rvm.io)

set :domain, 'x.x.x.x'
set :deploy_to, '/home/deploy/appname'
set :repository, 'git@bitbucket.org:username/appname.git'
#set :identity_file, "#{ENV['HOME']}/.ssh/id_rsa"
set :branch, 'master'
set :rails_env, 'production'

set :shared_paths, ['config/secrets.yml', 'log', 'tmp']
set :user, 'deploy'

task :environment do 
  invoke :'rvm:use[ruby-2.2.1@default]'
end

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! %[mkdir -p "#{deploy_to}/#{shared_path}/tmp"]
  queue! %[chmod g+rx,u+rwx "#{deploy_to}/#{shared_path}/tmp"]

  queue! %[mkdir -p "#{deploy_to}/#{shared_path}/tmp/pids"]
  queue! %[chmod g+rx,u+rwx "#{deploy_to}/#{shared_path}/tmp/pids"]

  queue! %[touch "#{deploy_to}/#{shared_path}/config/secrets.yml"]                                                                                        
  queue  %[echo "-----> Be sure to edit '#{deploy_to}/#{shared_path}/config/secrets.yml'."]
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: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'
    end
  end                                                                                                                                                     
end

config / sidekiq.yml包含

# Sample configuration file for Sidekiq.                                                                                                                  
# # Options here can still be overridden by cmd line args.
# # sidekiq -C config.yml
# ---
:verbose: false
:concurrency: 1
:queues:
  - [often, 7]
  - [default, 5]
  - [seldom, 3]

最后几个包含了“mina deploy --verbose'是

-----> Build finished

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

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

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

-----> Stop sidekiq
   Skip stopping sidekiq (no pid file found) 

-----> Start sidekiq
   $ bundle exec sidekiq -d -e production -C  /home/deploy/appname/current/config/sidekiq.yml -i 0 -P /home/deploy/appname/shared/pids/sideki       
   $ bundle exec sidekiq -d -e production -C /home/deploy/appname/current/config/sidekiq.yml -i 0 -P /home/deploy/appname/shared/pids/sidekiq.pid -L /home/deploy/appname/current/log/sidekiq.log

-----> Done. Deployed v37

问题是部署后sidekiq进程仍未在服务器上运行。有什么建议?

1 个答案:

答案 0 :(得分:0)

在您的生产实例上。请检查,是否存在sidekiq.log文件。如果存在,请查看此文件中的日志。

/your_app_name/current/log$ sudo nano sidekiq.log

您的实例中是否正在运行redis服务器? 使用sidekiq绑定redis服务器

制作文件config / redis.yml。写下面的代码 -

development:
     host: 'localhost'
     port: '6379'

test:
    host: 'localhost'
    port: '6379'

production:
    host: 'your_app_name-cache.name.0001.use1.cache.amazonaws.com'
    port: '6379'

确保服务器上必须有实例弹性缓存,并且应在特定缓存实例的安全组中的入站中添加自定义tcp规则。