【问题标题】:sidekiq not starting with mina deployment of rails 4 app.sidekiq 没有从 rails 4 应用程序的 mina 部署开始。
【发布时间】:2015-06-09 04:12:25
【问题描述】:

我有一个使用 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进程仍然没有在服务器上运行。有什么建议么?

【问题讨论】:

    标签: sidekiq ruby-on-rails-4.2


    【解决方案1】:

    在您的生产实例上。请检查是否存在 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'
    

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-05-20
      • 1970-01-01
      • 2013-08-13
      相关资源
      最近更新 更多