简体   繁体   English

Ruby on Rails:Capistrano 3部署错误

[英]Ruby on Rails: Capistrano 3 deployment error

I'm trying to deploy my rails 4 application in development mode. 我正在尝试在开发模式下部署rails 4应用程序。 When I try cap deploy:setup, it says staging is not set. 当我尝试cap deploy:setup时,它表示没有设置暂存。 Next I tried cap development deploy according to its suggestion and got the following error. 接下来我根据其建议尝试了cap开发部署,并得到以下错误。 Please help me with the deployment. 请帮我部署一下。

command: cap development deploy

cap aborted!
wrong number of arguments (5 for 1..2)
/home/divya/.rvm/gems/ruby-2.1.0/gems/capistrano-3.1.0/lib/capistrano/dsl/env.rb:38:in `server'
config/deploy/development.rb:5:in `<top (required)>'
/home/divya/.rvm/gems/ruby-2.1.0/gems/capistrano-3.1.0/lib/capistrano/setup.rb:15:in `load'
/home/divya/.rvm/gems/ruby-2.1.0/gems/capistrano-3.1.0/lib/capistrano/setup.rb:15:in `block (2 levels) in <top (required)>'
/home/divya/.rvm/gems/ruby-2.1.0/gems/capistrano-3.1.0/lib/capistrano/application.rb:15:in `run'
/home/divya/.rvm/gems/ruby-2.1.0/gems/capistrano-3.1.0/bin/cap:3:in `<top (required)>'
/home/divya/.rvm/gems/ruby-2.1.0/bin/cap:23:in `load'
/home/divya/.rvm/gems/ruby-2.1.0/bin/cap:23:in `<main>'
/home/divya/.rvm/gems/ruby-2.1.0/bin/ruby_executable_hooks:15:in `eval'
/home/divya/.rvm/gems/ruby-2.1.0/bin/ruby_executable_hooks:15:in `<main>'
Tasks: TOP => development
(See full trace by running task with --trace)

Using the following files: deploy.rb 使用以下文件: deploy.rb

set :application, 'timeTracker'
set :scm, :git
set :repository, "git@github.com:p/project.git"
set :user, "r"
set :scm_passphrase, "r"
set :branch, "master"
set :deploy_via, :remote_cache
set :stages, ["staging", "development", "production"]
set :default_stage, "development"
#set :rvm_ruby_string,           :local
#before 'deploy:setup', 'rvm:install_rvm'
#set :default_shell, "/bin/bash -l"
#set :rvm_type, :user
#set :rvm_install_with_sudo, true
#default_run_options[:pty] = true
#ssh_options[:forward_agent] = true
#ssh_options[:auth_methods] = "publickey"
# ssh_options[:keys] = "il.pem"
# set :ssh_options, {:auth_methods => "publickey"}
# set :ssh_options, {:keys => ["/home/c/mbk.pem"]}

# default_environment['PATH'] = '/usr/local/rvm/gems/ruby-1.9.3-p392:$PATH'
# default_environment['GEM_PATH']= '/usr/local/rvm/gems/ruby-1.9.3-p392'
# set :location, "http://ec2-23-23-59-41.compute-1.amazonaws.com"
# set :use_sudo, false
# ssh_options[:keys] = ["/home/c/ec2/mbk.pem"]

config/development.rb 配置/ development.rb

require "rvm/capistrano"
require 'capistrano/bundler'
server "IP", :app, :web, :db, :primary => true
set :deploy_to, "/var/www/t/"
set :branch, 'master'
set :scm_verbose, true
set :use_sudo, false
set :rails_env, "development" #added for delayed job 
set :rvm_type, :system
after 'deploy:update_code' do
# run "cd #{release_path}; RAILS_ENV=production rake assets:precompile"
run "cd #{release_path};"
run "mkdir -p #{release_path}/tmp/cache;"
run "chmod -R 777 #{release_path}/tmp/cache;"
run "mkdir -p #{release_path}/public/uploads;"
run "chmod -R 777 #{release_path}/public/uploads"
run "rm -rf #{release_path}/public/system"
# run "unlink #{release_path}/public/db_admin"
# run "unlink #{release_path}/public/blog"
run "ln -s #{shared_path}/system/ #{release_path}/public/" 
run "ln -s '/var/www/blog' #{release_path}/public/" 
run "mv  #{release_path}/config/database.example.yml #{release_path}/config/database.yml"

run "cd #{release_path} && bundle install"
run "cd #{release_path} && rake db:create"
run "cd #{release_path} && rake db:migrate"
# run "cd #{release_path} && RAILS_ENV=production rake assets:precompile"
# run "chown -R www-data:www-data #{release_path}/*"
# run "chmod -R 777 #{release_path}/log"
end

namespace :deploy do
  task :restart, :roles => :app, :except => { :no_release => true } do
  run "#{try_sudo} touch #{File.join(current_path,'tmp','restart.txt')}"
 end
end
wrong number of arguments (5 for 1..2)
/home/divya/.rvm/gems/ruby-2.1.0/gems/capistrano-3.1.0/lib/capistrano/dsl/env.rb:38:in `server'

It's telling you you're passing too many arguments to server . 它告诉你你向server传递了太多的参数。 Try replacing the first line with the second: 尝试用第二行替换第一行:

server "151.236.218.85", :app, :web, :db, :primary => true 
server "151.236.218.85", roles: [:app, :web, :db], :primary => true 

It's also possible to use roles: %w(app web db) if you find that cleaner. 如果你发现更清洁,也可以使用roles: %w(app web db)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM