http://www.fenxiangkuaile.com 建议使用chrome浏览器
有兴趣的人可以去看看。。
在这其中遇到了很多问题,不过还好都一一解决了
发一段部署文件的代码,因为这我研究了一天,希望对其他人有帮助
#主要是这个参数,如果没有设置,那么将会找不到 bundle命令 set :default_environment, { 'PATH' => /opt/ruby1.8.7/bin:$PATH } set :whenever_environment, defer { :production } set :whenever_command, bundle exec whenever require whenever/capistrano set :application, weijin ## 应用的名称 set :repository, [email protected]:test/abc.git # set :repository, Proc.new {--username #{scm_username} # --password #{scm_password} svn://localhost/test_app/trunk} # 资源库 # 资源库 set :scm, :git # Or: `accurev`, `bzr`, `cvs`, `darcs`, `git`, `mercurial`, `perforce`, `subversion` or `none` # set :scm_username, [email protected] # 资源库的用户名 set :scm_username, [email protected] # 资源库的用户名 set :scm_password, 111111 # 资源库的密码 # set :branch, origin/master set :branch, master # set :repository_cache, git_maint set :deploy_via, :remote_cache # et :deploy_via, :export # 在服务器上连接到源码库里去更新 # set :deploy_via, :copy # 在本地打包上传至服务器 # 服务器 set :user, test # 服务器 SSH 用户名 set :password, 111111 # 服务器 SSH 密码 set :deploy_to, /var/www/#{application} set :use_sudo, false # permission ssh_options[:forward_agent] = true role :web, 127.0.0.1 # 前端 Web 服务器 role :app, 127.0.0.1 # Rails 应用服务器 role :db, 127.0.0.1 , :primary => true # This is where Rails migrations will run # role :db, # if you're still using the script/reaper helper you will need # these http://github.com/rails/irs_process_scripts # If you are using Passenger mod_rails uncomment this: namespace :deploy do # task :start do ; end # task :stop do ; end # task :restart do # web.disable # migrate # cleanup # web.enable # end task :bundle do run cd #{current_release} && bundle install end task :restart, :roles => :app, :except => { :no_release => true } do # run /sbin/service nginx restart # run touch #{current_path}/tmp/restart.txt run #{try_sudo} touch #{File.join(current_path,'tmp','restart.txt')} end end after deploy:update_code do # run rake db:migrate run cp #{shared_path}/config/database.yml #{current_release}/config/database.yml # run cp #{shared_path}/config/environments/production.rb #{current_release}/config/environments/production.rb run mkdir -p #{current_release}/public/upload run ln -s /uploadfiles/users #{current_release}/public/upload/users run ln -s /uploadfiles/contents #{current_release}/public/upload/contents # pack js js_path = cd #{current_release}/public/javascripts && run #{js_path} packr -b default.js > default.min.js && mv default.min.js default.js run #{js_path} packr -b jquery.open-autocomplete.js > jquery.open-autocomplete.min.js && mv jquery.open-autocomplete.min.js jquery.open-autocomplete.js run #{js_path} packr -b jquery.open-box.js > jquery.open-box.min.js && mv jquery.open-box.min.js jquery.open-box.js run #{js_path} packr -b jquery.open-form.js > jquery.open-form.min.js && mv jquery.open-form.min.js jquery.open-form.js run #{js_path} packr -b jquery.open-menu.js > jquery.open-menu.min.js && mv jquery.open-menu.min.js jquery.open-menu.js end