heroku: ActionController :: RoutingError (Нет маршрута, соответствующего [GET] / newrelic)

ERROR

ActionController::RoutingError (No route matches [GET] "/newrelic")

# and I am getting error page for both staging and production heroku servers

Документация

https://devcenter.heroku.com/articles/newrelic

ДРАГОЦЕННЫЙ КАМЕНЬ

https://github.com/newrelic/rpm

# ruby 2.1.0p0
# rails 4.0.1

Обе переменные среды NEW_RELIC_LICENSE_KEY и NEW_RELIC_APP_NAME установлены в конфигурационную переменную heroku.

Gemfile

gem "newrelic_rpm", "~> 3.5.7.59"

config/newrelic.yml

common: &default_settings
  license_key: <%= ENV['NEW_RELIC_LICENSE_KEY'] %>
  app_name: <%= ENV["NEW_RELIC_APP_NAME"] %>
  monitor_mode: true
  developer_mode: false
  log_level: info

  browser_monitoring:
    auto_instrument: true

  audit_log:
    enabled: false
    capture_params: false

  transaction_tracer:
    enabled: true
    transaction_threshold: apdex_f
    record_sql: obfuscated
    stack_trace_threshold: 0.500

  error_collector:
    enabled: true
    capture_source: true
    ignore_errors: "ActionController::RoutingError,Sinatra::NotFound"

development:
  <<: *default_settings
  monitor_mode: true
  developer_mode: true

test:
  <<: *default_settings
  monitor_mode: false

production:
  <<: *default_settings
  monitor_mode: true

staging:
  <<: *default_settings
  monitor_mode: true
  app_name: <%= ENV["NEW_RELIC_APP_NAME"] %> (Staging)

[ПРИМЕЧАНИЕ: у меня есть два приложения, размещенных на heroku:]

  • (постановка) .herokuapp.com
  • (производство) .herokuapp.com

И я хочу настроить new-relic для обеих сред / серверов.

Также обратите внимание, что эта конфигурация отлично работает в среде разработки (localhost).

ИЗМЕНИТЬ

config/routes.rb

Demo::Application.routes.draw do
  root :to => "home#index"

  devise_for :users,:controllers => {:sessions => "sessions",:omniauth_callbacks => "omniauth_callbacks" }
  post '/tinymce_assets' => 'tinymce_assets#create'
  resources :home

  namespace :admin do
    resources :dashboards

    resources :users do
      member do
        get :reset
        put :reset_pw
        put :delete_record
        put :restore_user
      end
    end
  end

  resources :drives do
    member do
      put :destroy_drive
      post :add_consolidation
      put :delete_consolidation
      post :add_driveorganizer
      put :delete_drive_organizer
      put :restore_drirve
    end
    collection do
       get :recalculate_consolidation
    end
    resources :drive_details do
      resources :images
    end
  end

  resources :products do
    member do
      post :add_category
      put :destroy_pc
      put :delete_product
      put :restore_products
    end
  end

  resources :stores do
    member do
      put :delete_store
    end
  end

  resources :store_products do
    member do
      put :delete_storeproduct
      post :add_package_items
      put :delete_package_item
      put :restore_store_product
      get :get_product_price
    end
    collection do
      get :autocomplete_others
    end
  end

  resources :orders do
    member do
      put :delete_order
      put :restore_order
      get :charge_stripe
    end

    resources :order_items do
      collection do
        post :display_price
      end
      member do
        put :delete_record
      end
    end
  end

  resources :categories do
    member do
      put :delete_category
      put :restore_category
    end

    collection do
      get :move
    end
  end

  namespace :user do
    resources :campaigns do
      member do
        get :single_campaign
      end
      resources :stores 
      resources :carts do 
        collection do
          post :carts_update
          get :checkout_final
          get :payment
          post :payment
          get :update_payment
          get :update_payment_and_redirect
          get :confirmation
          post :confirmation
          get :finish
          post :confirmation_update
          put :empty_cart
          post :shelter_survey
        end
        member do
          put :destroy_oi
          put :checkout
        end
      end
    end
  end

  # The priority is based upon order of creation: first created -> highest priority.
  # See how all your routes lay out with "rake routes".

  # You can have the root of your site routed with "root"
  # root 'welcome#index'

  # Example of regular route:
  #   get 'products/:id' => 'catalog#view'

  # Example of named route that can be invoked with purchase_url(id: product.id)
  #   get 'products/:id/purchase' => 'catalog#purchase', as: :purchase

  # Example resource route (maps HTTP verbs to controller actions automatically):
  #   resources :products

  # Example resource route with options:
  #   resources :products do
  #     member do
  #       get 'short'
  #       post 'toggle'
  #     end
  #
  #     collection do
  #       get 'sold'
  #     end
  #   end

  # Example resource route with sub-resources:
  #   resources :products do
  #     resources :comments, :sales
  #     resource :seller
  #   end

  # Example resource route with more complex sub-resources:
  #   resources :products do
  #     resources :comments
  #     resources :sales do
  #       get 'recent', on: :collection
  #     end
  #   end

  # Example resource route with concerns:
  #   concern :toggleable do
  #     post 'toggle'
  #   end
  #   resources :posts, concerns: :toggleable
  #   resources :photos, concerns: :toggleable

  # Example resource route within a namespace:
  #   namespace :admin do
  #     # Directs /admin/products/* to Admin::ProductsController
  #     # (app/controllers/admin/products_controller.rb)
  #     resources :products
  #   end
end

Спасибо


person przbadu    schedule 27.05.2014    source источник
comment
Вы пробовали запускать рейк-маршруты, чтобы увидеть, что у вас получится?   -  person Martin    schedule 27.05.2014
comment
Он отлично работает в localhost и ломается в heroku, где вы ожидаете, что я буду запускать rake routes, локально ?? или в героку ??   -  person przbadu    schedule 27.05.2014
comment
Я добавил config/routes.rb файл. rake route | grep newrelic дает пустые маршруты (ничего не дает)   -  person przbadu    schedule 27.05.2014
comment
Вы используете Sinatra, поскольку кажется, что вы используете, поскольку вы спасаете Sinatra Исключения. Если да, то обязательно ли изменили производственную конфигурацию, как указано в документе? Также кажется, что Heroku настраивает ваш newrelic.yml для вас, поэтому убедитесь, что тот, который находится на heroku, совпадает с вашим, и, если нет, настройте его соответствующим образом с помощью конфигурации heroku.   -  person engineersmnky    schedule 27.05.2014
comment
Нет, я использую rails 4, я удалил sinatara, который не найден, но все еще получаю ошибку маршрутизации   -  person przbadu    schedule 27.05.2014
comment
Я настроил с newrelic.yml по curl https://gist.githubusercontent.com/rwdaigle/2253296/raw/newrelic.yml > config/newrelic.yml, который автоматически настроил мой файл newrelic.yml   -  person przbadu    schedule 27.05.2014


Ответы (1)


Исходя из полученной ошибки, похоже, что вы пытаетесь получить доступ к маршруту к агенту New Relic Ruby режим разработчика в тестовой и производственной средах. В режиме разработчика в ваше приложение устанавливается промежуточное ПО, которое отвечает на любой URL-адрес, перед которым стоит /newrelic. Поскольку вы включили режим разработчика в своей среде разработки (localhost) (для ключа developer_mode установлено значение true в вашем newrelic.yml под development), доступ к этому маршруту будет успешным, но он не удастся при постановке и производстве, потому что у вас нет режима разработчика. включен в этих средах.

Ваша текущая конфигурация обычно желательна, поскольку режим разработчика приводит к большим накладным расходам, которые составляют вообще недопустимо в продакшене. Вместо того, чтобы пытаться получить доступ к маршруту во время подготовки или производства, используйте его только во время разработки.

Вы также можете рассмотреть возможность обновления версии используемого вами агента, поскольку версия 3.5.7 не полностью поддерживает Ruby 2.0 или Rails 4. Более подробную информацию о выпусках можно найти в https://docs.newrelic.com/docs/releases/ruby.

person Alexis    schedule 27.05.2014
comment
вот и все ... большое спасибо, установка developer_mode для производственной среды решила ошибку маршрутизации. Большое спасибо, Алексис. - person przbadu; 28.05.2014