E
E
Earphone2018-08-03 09:16:35
Ruby on Rails
Earphone, 2018-08-03 09:16:35

Ruby on Rails 5 data loading breaks?

I am using Ruby on Rails 5 as backend and Angular 5 as frontend. I am running an application on localhost for testing purposes. And the problem is that Rails freezes from time to time. And because of this, Angular stops displaying information. And in order to resume Rails, you have to restart the process. But to reboot, you must first kill the process, and then restart it.
This results in the following error:

GET localhost:3000/users 504 (Gateway Time-out)
Failed to load localhost:3000/users: No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin ' localhost:4200 ' is therefore not allowed access. The response had HTTP status code 504.

How to fix it?
cors.rb:
Rails.application.config.middleware.insert_before 0, Rack::Cors do
  allow do
    origins '127.0.0.1:4200', 'localhost:4200'
    resource '*',
             :headers => :any,
             :expose  => ['access-token', 'expiry', 'token-type', 'uid', 'client'],
             :methods => [:get, :post, :options, :delete, :put]
  end
end

database.yml:
default: &default
  adapter: oracle_enhanced
  database: ********************************************
  username: **********
  password: **********

development:
  <<: *default
  database: ********************************************
  username: **********
  password: **********


test:
  <<: *default

production:
  <<: *default

gemfile:
source 'https://rubygems.org'

git_source(:github) do |repo_name|
  repo_name = "#{repo_name}/#{repo_name}" unless repo_name.include?("/")
  "https://github.com/#{repo_name}.git"
end


# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
gem 'rails', '~> 5.1.6'
# Use sqlite3 as the database for Active Record
gem 'ruby-oci8'
gem 'activerecord-oracle_enhanced-adapter'
# Use Puma as the app server
gem 'puma', '~> 3.7'
# Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder
# gem 'jbuilder', '~> 2.5'
# Use Redis adapter to run Action Cable in production
# gem 'redis', '~> 4.0'
# Use ActiveModel has_secure_password
# gem 'bcrypt', '~> 3.1.7'

# Use Capistrano for deployment
# gem 'capistrano-rails', group: :development

# Use Rack CORS for handling Cross-Origin Resource Sharing (CORS), making cross-origin AJAX possible
gem 'rack-cors'

group :development, :test do
  # Call 'byebug' anywhere in the code to stop execution and get a debugger console
  gem 'byebug', platform: :mri
end

group :development do
  gem 'listen', '>= 3.0.5', '< 3.2'
  # Spring speeds up development by keeping your application running in the background. Read more: https://github.com/rails/spring
  gem 'spring'
  gem 'spring-watcher-listen', '~> 2.0.0'
end

# Windows does not include zoneinfo files, so bundle the tzinfo-data gem
gem 'tzinfo-data', platforms: [:mingw, :mswin, :x64_mingw, :jruby]

gem 'omniauth'
gem 'devise_token_auth'
gem 'devise-i18n'
gem 'logs'
gem 'logstasher'

group :development do
  gem 'capistrano', require: false
  gem 'capistrano-rvm', require: false
  gem 'capistrano-rails', require: false
  gem 'capistrano-bundler', require: false
  gem 'capistrano3-puma', require: false
end

If you need something else to add, write.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
R
Roman Mirilaczvili, 2018-08-03
@Earphone

It's most likely being processed in the background. Either Orakl is working / stupidly waiting, or there is some kind of pre / post-processing on the application side (or a huge amount of data is being received).
Some of these requests

Started GET "/spr_type_events" for 10.12.4.5 at 2018-08-03 13:32:17 +0500
Started GET "/event_attributes" for 10.12.4.5 at 2018-08-03 13:32:18 +0500
Started GET "/ spr_events" for 10.12.4.5 at 2018-08-03 13:32:18 +0500
Started GET "/event_values" for 10.12.4.5 at 2018-08-03 13:32:18 +0500
possibly leading to a long processing time in the DBMS/application or a blocking operation.
1. Check how Oracle is behaving at this time.
2. Check the load on the OS where the application is running.
You can also try the same queries with a delay of a few seconds and check how this affects the load in the DBMS / application.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question