2011-05-16 147 views
4

一直在与Capistrano玩耍,以获得我的服务器和我的开发机器之间的自动部署。除了Capistrano似乎无法使用bundle exec命令启动我的服务器外,我几乎已经配置了它。我总是收到以下错误:Capistrano部署瘦服务器

编辑:配置文件现在居住在/var/www/apps/current/thin.yml

 
... 
    * executing "sudo -p 'sudo password: ' bundle exec thin start -C /var/www/thin.config.yml" 
    servers: ["85.255.206.157"] 
    [85.255.206.157] executing command 
** [out :: 85.255.206.157] Could not locate Gemfile 
    command finished in 216ms 
failed: "sh -c 'sudo -p '\\''sudo password: '\\'' bundle exec thin start -C /var/www/thin.config.yml'" on 85.255.206.157 

只有复制的最后一节与自己相关。整个文件的复制等工作正常。这只是启动似乎失败的集群。 这里是处理所有Capistrano的东西我deploy.rb文件:

编辑:该文件已被修改为如下:

require "bundler/capistrano" 

# define the application and Version Control settings 
set :application, "ESCO Matching Demo" 
set :repository, "svn://192.168.33.70/RubyOnRails/ESCO" 
set :deploy_via, :copy 

# Set the login credentials for Capistrano 
set :user, "kurt" 

# Tell Capistrano where to deploy 
set :deploy_to, "/var/www/apps" 

# Tell Capistrano the servers it can play with 
server "85.255.206.157", :app, :web, :db, :primary => true 

# Generate an additional task to fire up the thin clusters 
namespace :deploy do 
    desc "Start the Thin processes" 
    task :start do 
    sudo "bundle exec thin start -C thin.yml" 
    end 

    desc "Stop the Thin processes" 
    task :stop do 
    sudo "bundle exec thin stop -C thin.yml" 
    end 

    desc "Restart the Thin processes" 
    task :restart do 
    sudo "bundle exec thin restart -C thin.yml" 
    end 

    desc "Create a symlink from the public/cvs folder to the shared/system/cvs folder" 
    task :update_cv_assets, :except => {:no_release => true} do 
    run "ln -s #{shared_path}/cvs #{latest_release}/public/cvs" 
    end 
end 

# Define all the tasks that need to be running manually after Capistrano is finished. 
after "deploy:finalize_update", "deploy:update_cv_assets" 
after "deploy", "deploy:migrate" 

编辑:这是我thin.yml文件

--- 
pid: tmp/pids/thin.pid 
address: 0.0.0.0 
timeout: 30 
wait: 30 
port: 4000 
log: log/thin.log 
max_conns: 1024 
require: [] 

environment: production 
max_persistent_conns: 512 
server: 4 
daemonize: true 
chdir: /var/www/apps/current 

编辑:现在 以下问题发生:

  1. 我收到了找不到的Gemfile错误从我的系统上的最后一个步骤运行帽部署命令时:

  2. 迁移不进行服务器的启动

  3. 我可以” t似乎已经手动启动群集了。只有一个瘦身实例正在启动。

UPDATE: 这里是我部署到服务器上的宝石ENV设置。该信息是通过使用帽壳,然后运行命令获得:

 
==================================================================== 
Welcome to the interactive Capistrano shell! This is an experimental 
feature, and is liable to change in future releases. Type 'help' for 
a summary of how to use the shell. 
-------------------------------------------------------------------- 
cap> echo $PATH 
[establishing connection(s) to 85.255.206.157] 
Password: 
** [out :: 85.255.206.157] /usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games 
cap> gem env 
** [out :: 85.255.206.157] RubyGems Environment: 
** [out :: 85.255.206.157] - RUBYGEMS VERSION: 1.3.6 
** [out :: 85.255.206.157] - RUBY VERSION: 1.8.7 (2010-01-10 patchlevel 249) [x86_64-linux] 
** [out :: 85.255.206.157] - INSTALLATION DIRECTORY: /usr/lib/ruby/gems/1.8 
** [out :: 85.255.206.157] - RUBY EXECUTABLE: /usr/bin/ruby1.8 
** [out :: 85.255.206.157] - EXECUTABLE DIRECTORY: /usr/bin 
** [out :: 85.255.206.157] - RUBYGEMS PLATFORMS: 
** [out :: 85.255.206.157] - ruby 
** [out :: 85.255.206.157] - x86_64-linux 
** [out :: 85.255.206.157] - GEM PATHS: 
** [out :: 85.255.206.157] - /usr/lib/ruby/gems/1.8 
** [out :: 85.255.206.157] - /home/kurt/.gem/ruby/1.8 
** [out :: 85.255.206.157] - GEM CONFIGURATION: 
** [out :: 85.255.206.157] - :update_sources => true 
** [out :: 85.255.206.157] - :verbose => true 
** [out :: 85.255.206.157] - :benchmark => false 
** [out :: 85.255.206.157] - :backtrace => false 
** [out :: 85.255.206.157] - :bulk_threshold => 1000 
** [out :: 85.255.206.157] - REMOTE SOURCES: 
** [out :: 85.255.206.157] - http://rubygems.org/ 

回答

10

终于解决了问题... 首先,以获得捆绑应用程序与服务器environemnt发挥很好,下面的脚本做什么它应该做的事情:

require "bundler/capistrano" 
default_run_options[:pty] = true 

# define the application and Version Control settings 
set :application, "ESCO Matching Demo" 
set :repository, "svn://192.168.33.70/RubyOnRails/ESCO" 
set :deploy_via, :copy 
set :user, "kurt" 
set :deploy_to, "/var/www/apps" 

# Tell Capistrano the servers it can play with 

server "85.255.206.157", :app, :web, :db, :primary => true 

# Generate an additional task to fire up the thin clusters 
namespace :deploy do 
    desc "Start the Thin processes" 
    task :start do 
    run <<-CMD 
     cd /var/www/apps/current; bundle exec thin start -C config/thin.yml 
    CMD 
    end 

    desc "Stop the Thin processes" 
    task :stop do 
    run <<-CMD 
     cd /var/www/apps/current; bundle exec thin stop -C config/thin.yml 
    CMD 
    end 

    desc "Restart the Thin processes" 
    task :restart do 
    run <<-CMD 
     cd /var/www/apps/current; bundle exec thin restart -C config/thin.yml 
    CMD 
    end 

    desc "Create a symlink from the public/cvs folder to the shared/system/cvs folder" 
    task :update_cv_assets, :except => {:no_release => true} do 
    run <<-CMD 
     ln -s /var/www/shared/cvs /var/www/apps/current/public 
    CMD 
    end 
end 

# Define all the tasks that need to be running manually after Capistrano is finished. 
after "deploy:finalize_update", "deploy:update_cv_assets" 
after "deploy", "deploy:migrate" 

该脚本可以浏览很好地进入所需的部署结构并执行控制精简进程所需的命令。 问题在于,当以sudo方式运行这些命令时,cd命令没有完成。这背后的原因是cv只存在于shell中,并不是sudo的已知命令。

第二个问题是瘦配置。由于thin.yml中有一个小型服务器,因此瘦服务器无法启动。下面的脚本启动了一个运行在端口4000 - > 4003上的4个瘦服务器集群。

--- 
pid: tmp/pids/thin.pid 
address: 0.0.0.0 
timeout: 30 
wait: 30 
port: 4000 
log: log/thin.log 
max_conns: 1024 
require: [] 

environment: production 
max_persistent_conns: 512 
servers: 4 
daemonize: true 
chdir: /var/www/apps/current 
+4

也许它的确定只是做这样的'运行“CD#{的current_path} &&捆绑高管薄启动-C薄.yml“' – Shtirlic 2012-02-21 13:20:00

+0

可以让它在下一个项目上旋转,可能会使命令更具可读性。 – 2012-02-21 13:40:39

-2

曼,找出是GEM_HOME或GEM_PATH指向。必须是它。

+0

没有这些变量的定义变量系统 – 2011-05-19 06:47:50

+0

上定义,但仍然遇到了同样的问题 – 2011-05-24 06:47:55