如何通过Capistrano在生产中进入Rails控制台? [英] How to enter rails console on production via capistrano?
本文介绍了如何通过Capistrano在生产中进入Rails控制台?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想通过capistrano从本地计算机进入生产服务器上的rails控制台。
我发现了一些要点,例如 https://gist.github.com/813291 ,当我通过
I want to enter the rails console on production server from my local machine via capistrano. I found some gists, e.g. https://gist.github.com/813291 and when I enter console via
cap production console
我得到以下结果
192-168-0-100:foldername username $ cap console RAILS_ENV=production
* executing `console'
* executing "cd /var/www/myapp/current && rails console production"
servers: ["www.example.de"]
[www.example.de] executing command
[www.example.de] rvm_path=$HOME/.rvm/ $HOME/.rvm/bin/rvm-shell '1.9.3' -c 'cd /var/www/myapp/current && rails console production'
/var/www/myapp/releases/20120305102218/app/controllers/users_controller.rb:3: warning: already initialized constant VERIFY_PEER
Loading production environment (Rails 3.2.1)
Switch to inspect mode.
就这样...现在我可以输入一些文本了,但是什么也没发生...
and thats it... Now I can enter some text, but nothing happens...
有人对如何解决该问题或其他解决方案有想法吗?
Has anybody an idea how to get that work or another solution for my problem?
推荐答案
我已经为这种事情添加了自己的任务:
I've added my own tasks for this kind of thing:
namespace :rails do
desc "Remote console"
task :console, :roles => :app do
run_interactively "bundle exec rails console #{rails_env}"
end
desc "Remote dbconsole"
task :dbconsole, :roles => :app do
run_interactively "bundle exec rails dbconsole #{rails_env}"
end
end
def run_interactively(command)
server ||= find_servers_for_task(current_task).first
exec %Q(ssh #{user}@#{myproductionhost} -t '#{command}')
end
我现在说 cap rails:console
并获得一个控制台。
I now say cap rails:console
and get a console.
这篇关于如何通过Capistrano在生产中进入Rails控制台?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文