首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >本地版本有效,但生产版本不起作用。

问本地版本有效,但生产版本不起作用。
EN

Stack Overflow用户
提问于 2013-06-05 21:45:20
回答 1查看 541关注 0票数 1

上下文

最初,我的应用程序在本地和生产服务器(Heroku)上都正常工作。然后,我做了一个更改,过早地推到Heroku;更改破坏了生产版本,导致"500“错误的显示。这个应用程序仍然在我的本地服务器上工作。

为了解决这个问题,我运行了heroku rollback命令,以恢复到生产上的早期工作版本。生产版本现在正在工作。为了确保我的本地和生产副本与工作版本同步,我想我只需运行heroku git:clone -a myapp命令,这样我就可以将本地副本替换为工作产品副本。

问题

在将本地副本替换为生产中的工作副本之后,我试着推到Heroku (以验证一切正常工作)。我的本地版本仍然正常工作;但是,生产版本只是显示"505“错误,运行heroku rollback不再回滚到早期的工作版本。如何使生产版本正常工作?

为这种迂回的解释道歉。任何帮助都将不胜感激!

Gemfile:

代码语言:javascript
复制
source 'https://rubygems.org'

gem 'rails', '3.2.13'

# Bundle edge Rails instead:
# gem 'rails', :git => 'git://github.com/rails/rails.git'

group :development do
  gem 'sqlite3', '1.3.5'
end


# Gems used only for assets and not required
# in production environments by default.
group :assets do
  gem 'sass-rails',   '~> 3.2.3'
  gem 'coffee-rails', '~> 3.2.1'

  # See https://github.com/sstephenson/execjs#readme for more supported runtimes
  # gem 'therubyracer', :platforms => :ruby

  gem 'uglifier', '>= 1.0.3'
  # gem 'twitter-bootstrap-rails'
  gem 'libv8', '~> 3.11.8'
  gem 'less-rails'
  gem 'therubyracer'
end

gem 'jquery-rails'
gem 'twitter-bootstrap-rails'

# To use ActiveModel has_secure_password
# gem 'bcrypt-ruby', '~> 3.0.0'

# To use Jbuilder templates for JSON
# gem 'jbuilder'

# Use unicorn as the app server
# gem 'unicorn'

# Deploy with Capistrano
# gem 'capistrano'

# To use debugger
# gem 'debugger'
group :production do
  gem 'pg', '0.12.2'
end

运行heroku logs 命令的输出:

代码语言:javascript
复制
2013-06-05T21:54:39.324301+00:00 heroku[api]: Enable Logplex by ...@...com
2013-06-05T21:54:39.365512+00:00 heroku[api]: Release v2 created by ...@...com
2013-06-05T22:05:00.052911+00:00 heroku[slugc]: Slug compilation started
2013-06-05T22:07:13.861177+00:00 heroku[api]: Scale to web=1 by ...@...com
2013-06-05T22:07:14.437288+00:00 heroku[api]: Attach HEROKU_POSTGRESQL_BROWN resource by ...@...com
2013-06-05T22:07:14.466434+00:00 heroku[api]: Release v3 created by ...@...com
2013-06-05T22:07:14.531348+00:00 heroku[api]: Add DATABASE_URL config by ...@...com
2013-06-05T22:07:14.562176+00:00 heroku[api]: Release v4 created by ...@...com
2013-06-05T22:07:14.615023+00:00 heroku[api]: Add  config by ...@...com
2013-06-05T22:07:14.647163+00:00 heroku[api]: Release v5 created by ...@...com
2013-06-05T22:07:14.690706+00:00 heroku[api]: Deploy 0781b19 by ...@...com
2013-06-05T22:07:14.720746+00:00 heroku[api]: Release v6 created by ...@...com
2013-06-05T22:07:14.758968+00:00 heroku[api]: Deploy 0781b19 by ...@...com
2013-06-05T22:07:15.391452+00:00 heroku[slugc]: Slug compilation finished
2013-06-05T22:07:17.270346+00:00 heroku[web.1]: Starting process with command `bundle exec rails server -p 24519`
2013-06-05T22:07:21.081962+00:00 app[web.1]: DEPRECATION WARNING: You have Rails 2.3-style plugins in vendor/plugins! Support for these plugins will be removed in Rails 4.0. Move them out and bundle them in your Gemfile, or fold them in to your app as lib/myplugin/* and config/initializers/myplugin.rb. See the release notes for more on this: http://weblog.rubyonrails.org/2012/1/4/rails-3-2-0-rc2-has-been-released. (called from <top (required)> at /app/config/environment.rb:5)
2013-06-05T22:07:21.081844+00:00 app[web.1]: DEPRECATION WARNING: You have Rails 2.3-style plugins in vendor/plugins! Support for these plugins will be removed in Rails 4.0. Move them out and bundle them in your Gemfile, or fold them in to your app as lib/myplugin/* and config/initializers/myplugin.rb. See the release notes for more on this: http://weblog.rubyonrails.org/2012/1/4/rails-3-2-0-rc2-has-been-released. (called from <top (required)> at /app/config/environment.rb:5)
2013-06-05T22:07:24.020299+00:00 app[web.1]: => Booting WEBrick
2013-06-05T22:07:24.020299+00:00 app[web.1]: => Ctrl-C to shutdown server
2013-06-05T22:07:24.020299+00:00 app[web.1]: => Call with -d to detach
2013-06-05T22:07:24.020299+00:00 app[web.1]: => Rails 3.2.13 application starting in production on http://0.0.0.0:24519
2013-06-05T22:07:24.020299+00:00 app[web.1]: Connecting to database specified by DATABASE_URL
2013-06-05T22:07:24.195433+00:00 app[web.1]: [2013-06-05 22:07:24] INFO  ruby 1.9.2 (2011-07-09) [x86_64-linux]
2013-06-05T22:07:24.197238+00:00 app[web.1]: [2013-06-05 22:07:24] INFO  WEBrick::HTTPServer#start: pid=2 port=24519
2013-06-05T22:07:24.195268+00:00 app[web.1]: [2013-06-05 22:07:24] INFO  WEBrick 1.3.1
2013-06-05T22:07:24.563524+00:00 heroku[web.1]: State changed from starting to up
2013-06-05T22:20:29.360706+00:00 app[web.1]: Started GET "/" for 108.94.165.104 at 2013-06-05 22:20:29 +0000
2013-06-05T22:20:29.573466+00:00 app[web.1]: Processing by StudentsController#index as HTML
2013-06-05T22:20:29.721672+00:00 app[web.1]: Completed 500 Internal Server Error in 148ms
2013-06-05T22:20:29.729040+00:00 app[web.1]:                      pg_get_expr(d.adbin, d.adrelid), a.attnotnull, a.atttypid, a.atttypmod
2013-06-05T22:20:29.729040+00:00 app[web.1]:                                         ^
2013-06-05T22:20:29.729040+00:00 app[web.1]: :             SELECT a.attname, format_type(a.atttypid, a.atttypmod),
2013-06-05T22:20:29.729040+00:00 app[web.1]: 
2013-06-05T22:20:29.729040+00:00 app[web.1]:               FROM pg_attribute a LEFT JOIN pg_attrdef d
2013-06-05T22:20:29.729040+00:00 app[web.1]: ActiveRecord::StatementInvalid (PGError: ERROR:  relation "students" does not exist
2013-06-05T22:20:29.729040+00:00 app[web.1]:                 ON a.attrelid = d.adrelid AND a.attnum = d.adnum
2013-06-05T22:20:29.729040+00:00 app[web.1]: LINE 5:              WHERE a.attrelid = '"students"'::regclass
2013-06-05T22:20:29.729040+00:00 app[web.1]:              WHERE a.attrelid = '"students"'::regclass
2013-06-05T22:20:29.729327+00:00 app[web.1]:              ORDER BY a.attnum
2013-06-05T22:20:29.729327+00:00 app[web.1]: 
2013-06-05T22:20:29.729327+00:00 app[web.1]: ):
2013-06-05T22:20:29.729327+00:00 app[web.1]:   app/controllers/students_controller.rb:5:in `index'
2013-06-05T22:20:29.729040+00:00 app[web.1]:                AND a.attnum > 0 AND NOT a.attisdropped
2013-06-05T22:20:29.729327+00:00 app[web.1]: 
2013-06-05T22:20:29.732475+00:00 heroku[router]: at=info method=GET path=/ host=secret-brushlands-9122.herokuapp.com fwd="108.94.165.104" dyno=web.1 connect=7ms service=385ms status=500 bytes=643
2013-06-05T22:20:29.907973+00:00 heroku[router]: at=info method=GET path=/favicon.ico host=secret-brushlands-9122.herokuapp.com fwd="108.94.165.104" dyno=web.1 connect=1ms service=11ms status=200 bytes=0
2013-06-05T22:29:58.144871+00:00 heroku[api]: Deploy 0403476 by ...@...com
2013-06-05T22:29:58.167804+00:00 heroku[api]: Release v7 created by ...@...com
2013-06-05T22:29:58.206118+00:00 heroku[api]: Deploy 0403476 by ...@...com
2013-06-05T22:29:58.376314+00:00 heroku[web.1]: State changed from up to starting
2013-06-05T22:30:01.539107+00:00 heroku[web.1]: Starting process with command `bundle exec rails server -p 52191`
2013-06-05T22:30:01.701845+00:00 heroku[web.1]: Stopping all processes with SIGTERM
2013-06-05T22:30:02.512228+00:00 app[web.1]: [2013-06-05 22:30:02] ERROR SignalException: SIGTERM
2013-06-05T22:30:02.512228+00:00 app[web.1]:    /usr/local/lib/ruby/1.9.1/webrick/server.rb:90:in `select'
2013-06-05T22:30:12.438954+00:00 heroku[web.1]: Error R12 (Exit timeout) -> At least one process failed to exit within 10 seconds of SIGTERM
2013-06-05T22:30:12.439155+00:00 heroku[web.1]: Stopping remaining processes with SIGKILL
2013-06-05T22:30:14.361060+00:00 heroku[web.1]: Process exited with status 137
2013-06-05T22:30:15.586713+00:00 app[web.1]: DEPRECATION WARNING: You have Rails 2.3-style plugins in vendor/plugins! Support for these plugins will be removed in Rails 4.0. Move them out and bundle them in your Gemfile, or fold them in to your app as lib/myplugin/* and config/initializers/myplugin.rb. See the release notes for more on this: http://weblog.rubyonrails.org/2012/1/4/rails-3-2-0-rc2-has-been-released. (called from <top (required)> at /app/config/environment.rb:5)
2013-06-05T22:30:15.586566+00:00 app[web.1]: DEPRECATION WARNING: You have Rails 2.3-style plugins in vendor/plugins! Support for these plugins will be removed in Rails 4.0. Move them out and bundle them in your Gemfile, or fold them in to your app as lib/myplugin/* and config/initializers/myplugin.rb. See the release notes for more on this: http://weblog.rubyonrails.org/2012/1/4/rails-3-2-0-rc2-has-been-released. (called from <top (required)> at /app/config/environment.rb:5)
2013-06-05T22:30:35.092923+00:00 app[web.1]: => Call with -d to detach
2013-06-05T22:30:35.092923+00:00 app[web.1]: => Ctrl-C to shutdown server
2013-06-05T22:30:35.092923+00:00 app[web.1]: Connecting to database specified by DATABASE_URL
2013-06-05T22:30:35.092923+00:00 app[web.1]: => Booting WEBrick
2013-06-05T22:30:35.092923+00:00 app[web.1]: => Rails 3.2.13 application starting in production on http://0.0.0.0:52191
2013-06-05T22:30:35.594816+00:00 app[web.1]: [2013-06-05 22:30:35] INFO  WEBrick 1.3.1
2013-06-05T22:30:35.594816+00:00 app[web.1]: [2013-06-05 22:30:35] INFO  ruby 1.9.2 (2011-07-09) [x86_64-linux]
2013-06-05T22:30:35.595558+00:00 app[web.1]: [2013-06-05 22:30:35] INFO  WEBrick::HTTPServer#start: pid=2 port=52191
2013-06-05T22:30:35.990236+00:00 heroku[web.1]: State changed from starting to up
2013-06-05T22:30:38.042484+00:00 app[web.1]: Started GET "/" for 108.94.165.104 at 2013-06-05 22:30:38 +0000
2013-06-05T22:30:38.423594+00:00 app[web.1]: Processing by StudentsController#index as HTML
2013-06-05T22:30:39.528941+00:00 heroku[router]: at=info method=GET path=/ host=secret-brushlands-9122.herokuapp.com fwd="108.94.165.104" dyno=web.1 connect=2ms service=1523ms status=500 bytes=643
2013-06-05T22:30:39.706864+00:00 heroku[router]: at=info method=GET path=/favicon.ico host=secret-brushlands-9122.herokuapp.com fwd="108.94.165.104" dyno=web.1 connect=2ms service=24ms status=200 bytes=0
2013-06-05T22:30:39.512419+00:00 app[web.1]: Completed 500 Internal Server Error in 1088ms
2013-06-05T22:30:39.514250+00:00 app[web.1]: 
2013-06-05T22:30:39.514250+00:00 app[web.1]:                 ON a.attrelid = d.adrelid AND a.attnum = d.adnum
2013-06-05T22:30:39.514430+00:00 app[web.1]:   app/controllers/students_controller.rb:5:in `index'
2013-06-05T22:30:39.514250+00:00 app[web.1]:                AND a.attnum > 0 AND NOT a.attisdropped
2013-06-05T22:30:39.514430+00:00 app[web.1]:              ORDER BY a.attnum
2013-06-05T22:30:39.514430+00:00 app[web.1]: ):
2013-06-05T22:30:39.514250+00:00 app[web.1]: LINE 5:              WHERE a.attrelid = '"students"'::regclass
2013-06-05T22:30:39.514250+00:00 app[web.1]:                                         ^
2013-06-05T22:30:39.514250+00:00 app[web.1]: ActiveRecord::StatementInvalid (PGError: ERROR:  relation "students" does not exist
2013-06-05T22:30:39.514250+00:00 app[web.1]: :             SELECT a.attname, format_type(a.atttypid, a.atttypmod),
2013-06-05T22:30:39.514250+00:00 app[web.1]:                      pg_get_expr(d.adbin, d.adrelid), a.attnotnull, a.atttypid, a.atttypmod
2013-06-05T22:30:39.514250+00:00 app[web.1]:               FROM pg_attribute a LEFT JOIN pg_attrdef d
2013-06-05T22:30:39.514250+00:00 app[web.1]:              WHERE a.attrelid = '"students"'::regclass
2013-06-05T22:30:39.514430+00:00 app[web.1]: 
2013-06-05T22:30:39.514430+00:00 app[web.1]: 

更新:

我很好奇创建一个新的Heroku遥控器是否能解决这个问题,所以我删除了http://nameless-brook-8163.herokuapp.com/,并将新的遥控器设置为http://secret-brushlands-9122.herokuapp.com/。不幸的是,问题依然存在。

我按照下面的建议运行了'heroku rake db:migrate‘,得到了以下输出:

代码语言:javascript
复制
heroku run rake db:migrate
Running `rake db:migrate` attached to terminal... up, run.6596
DEPRECATION WARNING: You have Rails 2.3-style plugins in vendor/plugins! Support for these plugins will be removed in Rails 4.0. Move them out and bundle them in your Gemfile, or fold them in to your app as lib/myplugin/* and config/initializers/myplugin.rb. See the release notes for more on this: http://weblog.rubyonrails.org/2012/1/4/rails-3-2-0-rc2-has-been-released. (called from <top (required)> at /app/Rakefile:7)
DEPRECATION WARNING: You have Rails 2.3-style plugins in vendor/plugins! Support for these plugins will be removed in Rails 4.0. Move them out and bundle them in your Gemfile, or fold them in to your app as lib/myplugin/* and config/initializers/myplugin.rb. See the release notes for more on this: http://weblog.rubyonrails.org/2012/1/4/rails-3-2-0-rc2-has-been-released. (called from <top (required)> at /app/Rakefile:7)
rake aborted!
Invalid DATABASE_URL
(erb):9:in `rescue in <main>'
(erb):6:in `<main>'
/app/vendor/bundle/ruby/1.9.1/gems/railties-3.2.13/lib/rails/application/configuration.rb:115:in `database_configuration'
/app/vendor/bundle/ruby/1.9.1/gems/activerecord-3.2.13/lib/active_record/railtie.rb:78:in `block (2 levels) in <class:Railtie>'
/app/vendor/bundle/ruby/1.9.1/gems/activesupport-3.2.13/lib/active_support/lazy_load_hooks.rb:36:in `instance_eval'
/app/vendor/bundle/ruby/1.9.1/gems/activesupport-3.2.13/lib/active_support/lazy_load_hooks.rb:36:in `execute_hook'
/app/vendor/bundle/ruby/1.9.1/gems/activesupport-3.2.13/lib/active_support/lazy_load_hooks.rb:43:in `block in run_load_hooks'
/app/vendor/bundle/ruby/1.9.1/gems/activesupport-3.2.13/lib/active_support/lazy_load_hooks.rb:42:in `each'
/app/vendor/bundle/ruby/1.9.1/gems/activesupport-3.2.13/lib/active_support/lazy_load_hooks.rb:42:in `run_load_hooks'
/app/vendor/bundle/ruby/1.9.1/gems/activerecord-3.2.13/lib/active_record/base.rb:720:in `<top (required)>'
/app/vendor/bundle/ruby/1.9.1/gems/activerecord-3.2.13/lib/active_record/railties/databases.rake:25:in `block (2 levels) in <top (required)>'
/app/vendor/bundle/ruby/1.9.1/gems/rake-10.0.4/lib/rake/task.rb:246:in `call'
/app/vendor/bundle/ruby/1.9.1/gems/rake-10.0.4/lib/rake/task.rb:246:in `block in execute'
/app/vendor/bundle/ruby/1.9.1/gems/rake-10.0.4/lib/rake/task.rb:241:in `each'
/app/vendor/bundle/ruby/1.9.1/gems/rake-10.0.4/lib/rake/task.rb:241:in `execute'
/app/vendor/bundle/ruby/1.9.1/gems/rake-10.0.4/lib/rake/task.rb:184:in `block in invoke_with_call_chain'
/app/vendor/bundle/ruby/1.9.1/gems/rake-10.0.4/lib/rake/task.rb:177:in `invoke_with_call_chain'
/app/vendor/bundle/ruby/1.9.1/gems/rake-10.0.4/lib/rake/task.rb:205:in `block in invoke_prerequisites'
/app/vendor/bundle/ruby/1.9.1/gems/rake-10.0.4/lib/rake/task.rb:203:in `each'
/app/vendor/bundle/ruby/1.9.1/gems/rake-10.0.4/lib/rake/task.rb:203:in `invoke_prerequisites'
/app/vendor/bundle/ruby/1.9.1/gems/rake-10.0.4/lib/rake/task.rb:183:in `block in invoke_with_call_chain'
/app/vendor/bundle/ruby/1.9.1/gems/rake-10.0.4/lib/rake/task.rb:177:in `invoke_with_call_chain'
/app/vendor/bundle/ruby/1.9.1/gems/rake-10.0.4/lib/rake/task.rb:170:in `invoke'
/app/vendor/bundle/ruby/1.9.1/gems/rake-10.0.4/lib/rake/application.rb:143:in `invoke_task'
/app/vendor/bundle/ruby/1.9.1/gems/rake-10.0.4/lib/rake/application.rb:101:in `block (2 levels) in top_level'
/app/vendor/bundle/ruby/1.9.1/gems/rake-10.0.4/lib/rake/application.rb:101:in `each'
/app/vendor/bundle/ruby/1.9.1/gems/rake-10.0.4/lib/rake/application.rb:101:in `block in top_level'
/app/vendor/bundle/ruby/1.9.1/gems/rake-10.0.4/lib/rake/application.rb:110:in `run_with_threads'
/app/vendor/bundle/ruby/1.9.1/gems/rake-10.0.4/lib/rake/application.rb:95:in `top_level'
/app/vendor/bundle/ruby/1.9.1/gems/rake-10.0.4/lib/rake/application.rb:73:in `block in run'
/app/vendor/bundle/ruby/1.9.1/gems/rake-10.0.4/lib/rake/application.rb:160:in `standard_exception_handling'
/app/vendor/bundle/ruby/1.9.1/gems/rake-10.0.4/lib/rake/application.rb:70:in `run'
Tasks: TOP => db:migrate => db:load_config
(See full trace by running task with --trace)
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2013-06-11 21:14:45

问题似乎是我的CSS文件中有一个开放的注释(*/)。当我试图用命令编译这些资产时,我注意到了这一点:

代码语言:javascript
复制
RAILS_ENV=production bundle exec rake assets:precompile

得到了错误..。

代码语言:javascript
复制
rake aborted!
Invalid CSS after "*/": expected identifier, was "/* Sections"

我删除了多余的"*/",强行推到Heroku (git push -f heroku master),删除了index.html,并查看了正确的页面。

感谢大家的帮助和建议!

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/16950434

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档