2015-06-09 39 views
1

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

我的部署脚本是

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, '[email protected]: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[[email protected]]' 
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 

配置/ 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] 

过去的几年中含有的 '米娜部署--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进程仍未在服务器上运行。有什么建议么?

回答

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规则实例elasticache应在入境被添加在特定的缓存实例的安全组。