我使用rails构建了一个示例应用程序,并尝试使用capistrano将其部署到bluehost。 但我没有这样做。我按照本http://vasil-y.com/2012/08/21/rails-capistrano-git-bluehost/
中提到的说明进行操作这是我的config / deploy.rb的内容:
require 'bundler/capistrano'
set :application, "rails_scaffold"
# BlueHost SSH user
set :user, "username"
# App Domain
set :domain, "example.com"
# We don't need sudo on BlueHost
set :use_sudo, false
# git is our SCM
set :scm, :git
# master is our default git branch
set :branch, "master"
# Use local git repository
set :repository, "#{domain}:/home/#{user}/rails_apps/#{application}"
set :local_repository, "."
# Checkout, compress and send a local copy
set deploy_via, :copy
set deploy_to, "/home/#{user}/rails_apps/#{application}"
# We have all components of the app on the same server
server domain, :app, :web, :db, :primary => true
namespace :deploy do
task :start do ; end
task :stop do ; end
# Touch tmp/restart.txt to tell Phusion Passenger about new version
task :restart, :roles => :app, :except => { :no_release => true } do
run "touch #{File.join(current_path, 'tmp', 'restart.txt')}"
end
end
# Clean-up old releases
after "deploy:restart", "deploy:cleanup"
但是当我运行cap deploy:setup命令时,我收到以下错误:
/home/swaroop/.rvm/gems/ruby-1.9.3-p362/gems/capistrano-2.14.2/lib/capistrano/configuration/variables.rb:22:in `set': invalid variable `/u/apps/rails_scaffold' (variables must begin with an underscore, or a lower-case letter) (ArgumentError)
它表示应用程序名称必须以下划线或小写字母开头。我的应用程序名称看起来有效。 我在这里做错了什么?
谢谢
答案 0 :(得分:2)
您的几个set
调用的参数不是符号:
set deploy_via, :copy
set deploy_to, "/home/#{user}/rails_apps/#{application}"
那些应该是:
set :deploy_via, :copy
set :deploy_to, "/home/#{user}/rails_apps/#{application}"
(请注意deploy_via
和deploy_to
之前的冒号)
如果我们检查包含:application
的行中发生的情况,您可以看到与:deploy_to
变量相关的原因:它首先调用deploy_to
方法(因为您是错过了冒号,它看起来像是一个方法调用),而deploy_to
默认为"/u/apps/#{application}"
中的_cset(:deploy_to) { "/u/apps/#{application}" }
:
set "/u/apps/#{application}", "/home/#{user}/rails_apps/#{application}"
实际上,您的代码正在尝试运行此代码:
"/u/apps/#{application}"
但{{1}}不是Capistrano中的有效变量名。将冒号添加到这些行应该修复它。