Capistrano-Sidekiq在重新启动时部署错误

时间:2016-12-14 19:21:10

标签: ruby-on-rails capistrano sidekiq

我使用capistrano部署我的rails应用程序,但是我收到以下错误:

Skipping task `sidekiq:restart'.
Capistrano tasks may only be invoked once. Since task `sidekiq:restart' was previously invoked, invoke("sidekiq:restart") at config/deploy.rb:49 will be skipped.
If you really meant to run this task again, first call Rake::Task["sidekiq:restart"].reenable
THIS BEHAVIOR MAY CHANGE IN A FUTURE VERSION OF CAPISTRANO. Please join the conversation here if this affects you.
https://github.com/capistrano/capistrano/issues/1686

除此之外,我认为即使是第一次命令也不起作用,因为sidekiq没有运行。我可以手动启动它,但我相信即使没有运行,它仍然应该启动,对吧?

我的部署/ production.rb:

# server-based syntax
# ======================
# Defines a single server with a list of roles and multiple properties.
# You can define all roles on a single server, or split them:

set :stage, :production
set :full_app_name, "#{fetch(:application)}_#{fetch(:stage)}"

# Using remote cache to deploy
set :deploy_via, :remote_cache

server '35.160.22.104', user: 'ubuntu', roles: %w{app db web}

# role-based syntax
# ==================

# Defines a role with one or multiple servers. The primary server in each
# group is considered to be the first unless any  hosts have the primary
# property set. Specify the username and a domain or IP for the server.
# Don't use `:all`, it's a meta role.

# role :app, %w{deploy@example.com}, my_property: :my_value
# role :web, %w{user1@primary.com user2@additional.com}, other_property: :other_value
# role :db,  %w{deploy@example.com}



# Configuration
# =============
# You can set any configuration variable like in config/deploy.rb
# These variables are then only loaded and set in this stage.
# For available Capistrano configuration variables see the documentation page.
# http://capistranorb.com/documentation/getting-started/configuration/
# Feel free to add new variables to customise your setup.
set :rails_env, :production
set :pty, true

# number of unicorn workers
# set :unicorn_worker_count, 5


# Custom SSH Options
# ==================
# You may pass any option but keep in mind that net/ssh understands a
# limited set of options, consult the Net::SSH documentation.
# http://net-ssh.github.io/net-ssh/classes/Net/SSH.html#method-c-start
#
set :ssh_options, {
  keys: %w(/home/ronanlopes/Pems/hybrazil-impulso.pem ~/.ssh/id_rsa),
  forward_agent: true,
  auth_methods: %w(publickey)
}


# Sidekiq
set :sidekiq_config, File.join(current_path, 'config', 'sidekiq.yml')
set :sidekiq_log, File.join(shared_path, 'log', 'sidekiq.log')
set :sidekiq_pid, File.join(shared_path, 'tmp', 'pids', 'sidekiq.pid')

我的deploy.rb:

# config valid only for current version of Capistrano
lock '3.7.0'

set :application, 'hybrazil'
set :repo_url, 'git@github.com:fneto/hybrazil.git'
set :user, 'ubuntu'


# Need this so capistrano creates the directories as "ubuntu" user
set :use_sudo, false

# Default deploy_to directory is /var/www/my_app_name
set :deploy_to, '/home/ubuntu/hybrazil'

set :passenger_restart_with_touch, true

set :rvm_type, :user
set :rvm_ruby_version, '2.3.1'

# Default value for :scm is :git
# set :scm, :git

# Default value for :format is :airbrussh.
# set :format, :airbrussh

# You can configure the Airbrussh format using :format_options.
# These are the defaults.
# set :format_options, command_output: true, log_file: 'log/capistrano.log', color: :auto, truncate: :auto

# Default value for :pty is false
# set :pty, true

# Default value for :linked_files is []
# append :linked_files, 'config/database.yml', 'config/secrets.yml'

# Default value for linked_dirs is []
# append :linked_dirs, 'log', 'tmp/pids', 'tmp/cache', 'tmp/sockets', 'public/system'

# Default value for default_env is {}
# set :default_env, { path: "/opt/ruby/bin:$PATH" }

set :linked_files, %w{config/database.yml config/secrets.yml}
set :linked_dirs, %w{log tmp/pids tmp/cache tmp/sockets vendor/bundle public/system public/uploads}

namespace :deploy do

  desc 'Restart application'
  task :restart do
    invoke 'sidekiq:restart'
    on roles(:app), in: :sequence, wait: 5 do
      execute :touch, release_path.join('tmp/restart.txt')
    end
  end

end

任何帮助将不胜感激。谢谢!

1 个答案:

答案 0 :(得分:0)

对我来说,将pty设置为false工作。仍然不知道为什么,但如果有人这样做,会很感激评论的解释。谢谢!

相关问题