ruby-on-rails – 使用反引号在Rails应用程序中启动另一个Rails
我目前正在开发一个Rails应用程序,它作为另一个Rails应用程序的更新程序.
我有更新过程, >下载新版本zip 我在最后一步遇到了问题. 当我跑: Dir.chdir('../other-project') `bundle exec rails server -d -p 3000` 从更新程序的应用程序,它似乎是从更新程序包中提取 更新程序是用Rails 4编写的,它正在更新的应用程序是rails 3. 当我尝试启动服务器时,我得到以下内容: /home/vagrant/.rbenv/versions/2.0.0-p481/lib/ruby/gems/2.0.0/gems/railties-4.1.4/lib/rails/railtie/configuration.rb:95:in `method_missing': undefined method `handlebars' for #<Rails::Application::Configuration:0x007f9de18de100> (NoMethodError) from /home/vagrant/apps/other-project/config/application.rb:22:in `<class:Application>' from /home/vagrant/apps/other-project>' from /home/vagrant/apps/other-project/config/application.rb:13:in `<top (required)>' from /home/vagrant/.rbenv/versions/2.0.0-p481/lib/ruby/gems/2.0.0/gems/railties-4.1.4/lib/rails/commands/commands_tasks.rb:79:in `require' from /home/vagrant/.rbenv/versions/2.0.0-p481/lib/ruby/gems/2.0.0/gems/railties-4.1.4/lib/rails/commands/commands_tasks.rb:79:in `block in server' from /home/vagrant/.rbenv/versions/2.0.0-p481/lib/ruby/gems/2.0.0/gems/railties-4.1.4/lib/rails/commands/commands_tasks.rb:76:in `tap' from /home/vagrant/.rbenv/versions/2.0.0-p481/lib/ruby/gems/2.0.0/gems/railties-4.1.4/lib/rails/commands/commands_tasks.rb:76:in `server' from /home/vagrant/.rbenv/versions/2.0.0-p481/lib/ruby/gems/2.0.0/gems/railties-4.1.4/lib/rails/commands/commands_tasks.rb:40:in `run_command!' from /home/vagrant/.rbenv/versions/2.0.0-p481/lib/ruby/gems/2.0.0/gems/railties-4.1.4/lib/rails/commands.rb:17:in `<top (required)>' from script/rails:6:in `require' from script/rails:6:in `<main>' 从这个输出我可以告诉它它正试图使用??不正确版本的铁路… 当我手动cd ../other-project并捆绑exec rails server -d -p 3000时,它工作正常. 我可以使用任何bash技巧来解决这个问题吗? 谢谢! 解决方法
好吧,我花了一个上午对此进行故障排除,我找到了解决方案!
您所要做的就是在以下位置之前设置BUNDLE_GEMFILE环境变量: 捆绑exec rails server -d -p 3000 似乎Bundler需要一些帮助才能找到项目Gemfile,因为我正在尝试在当前包中启动另一个应用程序,这是我创建的用于控制此更新程序将负责更新的应用程序的类. 我很高兴地说start方法最终按预期工作! class AppController @dir = Rails.root.join('../','Other-app/') def self.running? File.exist?("#{@dir}/tmp/pids/server.pid") end def self.start if running? puts "app already running" else Dir.chdir(@dir) puts "starting app..." `BUNDLE_GEMFILE=Gemfile bundle exec rails server -d -p 3000` puts "app started" end end def self.kill if not running? puts "app already dead" else Dir.chdir(@dir) puts "killing app..." `kill $(cat tmp/pids/server.pid)` puts "app dead" end end def self.restart if running? kill start else start end end end (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |