问题描述
我正在尝试将Ruby on Rails应用程序设置为部署到精简集群。当我使用 bundle exec手动启动服务器上的精简集群时,thin start -C config / thin.yml
一切正常。但是,当我通过Capistrano运行相同的命令时,它就会死掉,并且日志显示:
I'm trying to setup my Ruby on Rails application to deploy to a Thin cluster. When I manually start the thin cluster on the server using bundle exec thin start -C config/thin.yml
everything works fine. However when I run the same command via Capistrano it just dies and the log displays:
/shared/bundle/ruby/1.9.1/gems /activerecord-3.2.6/lib/active_record/connection_adapters/abstract/connection_specification.rb:45:在`resolve_hash_connection'中:数据库配置未指定适配器(ActiveRecord :: AdapterNotSpecified)
我很茫然,我使用capistrano脚本中定义的用户帐户登录服务器。
I'm at a loss, I log into the server using the same user account as defined in the capistrano script.
我capistrano瘦任务:
My capistrano Thin tasks:
namespace :deploy do
task :start do
run "cd #{current_path}; bundle exec thin start -C config/thin.yml"
end
task :stop do
run "cd #{current_path}; bundle exec thin stop -C config/thin.yml"
end
task :restart do
run "cd #{current_path}; bundle exec thin restart -C config/thin.yml"
end
end
这是我的thin.yml:
Here is my thin.yml:
---
chdir: /var/www/rails/myapp/current
environment: staging
address: 0.0.0.0
port: 3000
timeout: 30
log: log/thin.log
pid: tmp/pids/thin.pid
max_conns: 1024
max_persistent_conns: 512
require: []
wait: 30
servers: 2
daemonize: true
任何帮助将不胜感激
推荐答案
我需要在每个步骤上明确设置RAILS_ENV
I needed to explicitly set the RAILS_ENV on each step.
运行 cd#{current_path};。 RAILS_ENV =#{rails_env}捆绑执行精简启动-C config / thin.yml
Capistrano似乎没有能力我们的环境变量
It doesn't seem that Capistrano is picking up our environment variable
以下是相关文章:
这篇关于Thin / Capistrano无法连接到数据库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!