gpt4 book ai didi

ruby-on-rails - Capistrano 部署瘦服务器

转载 作者:行者123 更新时间:2023-12-04 23:30:18 25 4
gpt4 key购买 nike

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

编辑:配置文件现在位于/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 216msfailed: "sh -c 'sudo -p '\\''sudo password: '\\'' bundle exec thin start -C /var/www/thin.config.yml'" on 85.255.206.157

Only copied the last section that's relevant. The whole copying of the files etc works fine. It's just starting the cluster that seems to be failing.Here is my deploy.rb file that handles all Capistrano stuff:

EDIT: The file has been modified to the following:

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

编辑:
现在出现以下问题:
  • 在最后一步从我的系统运行 cap deploy 命令时,我收到了无法找到 GemFile 错误:服务器启动
  • 不执行迁移
  • 我似乎也无法再手动启动集群了。只有一个thin 实例正在启动。

  • 更新:
    这是我要部署到的服务器的 gem env 设置。此信息是通过使用 cap shell 然后运行以下命令获得的:


    ================================================== ==================
    欢迎使用交互式 Capistrano shell!这是一个实验
    功能,并且在 future 的版本中可能会发生变化。输入“帮助”
    如何使用 shell 的总结。
    -------------------------------------------------- ------------------
    帽> 回声 $PATH
    [建立与 85.255.206.157 的连接]
    密码:
    ** [out::85.255.206.157]/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games
    帽> gem 环境
    ** [out::85.255.206.157] RubyGems 环境:
    ** [出::85.255.206.157] - ruby 版本:1.3.6
    ** [out::85.255.206.157] - RUBY 版本:1.8.7 (2010-01-10 patchlevel 249) [x86_64-linux]
    ** [out::85.255.206.157] - 安装目录:/usr/lib/ruby/gems/1.8
    ** [out::85.255.206.157] - ruby 可执行文件:/usr/bin/ruby1.8
    ** [out::85.255.206.157] - 可执行目录:/usr/bin
    ** [出::85.255.206.157] - RUBYGEMS 平台:
    ** [出::85.255.206.157] - ruby
    ** [输出::85.255.206.157] - x86_64-linux
    ** [出::85.255.206.157] - gem 路径:
    ** [输出::85.255.206.157] -/usr/lib/ruby/gems/1.8
    ** [出::85.255.206.157] -/home/kurt/.gem/ruby/1.8
    ** [out::85.255.206.157] - gem 配置:
    ** [输出::85.255.206.157] - :update_sources => 真
    ** [out::85.255.206.157] - :verbose => true
    ** [输出::85.255.206.157] - :benchmark => false
    ** [out::85.255.206.157] - :backtrace => false
    ** [输出::85.255.206.157] - :bulk_threshold => 1000
    ** [出::85.255.206.157] - 远程来源:
    ** [出::85.255.206.157] - http://rubygems.org/

    最佳答案

    终于解决了问题...
    首先,为了让 bundle 应用程序与环境服务器很好地配合,以下脚本执行它应该做的事情:

    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"

    该脚本可以很好地导航到所需的部署结构并执行控制瘦进程所需的命令。 问题是 cd 命令在以 sudo 运行时没有完成。这背后的原因是 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

    关于ruby-on-rails - Capistrano 部署瘦服务器,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6018591/

    25 4 0
    Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
    广告合作:1813099741@qq.com 6ren.com