Rails 3.2 messy logs - ruby-on-rails-3

Every request I make on my local server is generating huge amounts of log messages like the following:
[aa6f821b342dc08800f423e86d24db20] [127.0.0.1] Rendered shared/_footer.html.erb (3.5ms)
[aa6f821b342dc08800f423e86d24db20] [127.0.0.1] Completed 200 OK in 2684ms (Views: 590.0ms | ActiveRecord: 191.8ms)
[cd2037fee6bd082a4119d8799a7e7439] [127.0.0.1]
[cd2037fee6bd082a4119d8799a7e7439] [127.0.0.1]
[cd2037fee6bd082a4119d8799a7e7439] [127.0.0.1] Started GET "/assets/global.css?body=1" for 127.0.0.1 at 2013-01-18 19:39:22 -0500
[cd2037fee6bd082a4119d8799a7e7439] [127.0.0.1] Served asset /global.css - 304 Not Modified (3ms)
[5f2da9e4e857fb4e8c024a95a424fc14] [127.0.0.1]
[5f2da9e4e857fb4e8c024a95a424fc14] [127.0.0.1]
[5f2da9e4e857fb4e8c024a95a424fc14] [127.0.0.1] Started GET "/assets/caEntry.css?body=1" for 127.0.0.1 at 2013-01-18 19:39:22 -0500
[5f2da9e4e857fb4e8c024a95a424fc14] [127.0.0.1] Served asset /caEntry.css - 304 Not Modified (2ms)
[708c81464666f10e1b2a46e1dbf4af71] [127.0.0.1]
[708c81464666f10e1b2a46e1dbf4af71] [127.0.0.1]
[708c81464666f10e1b2a46e1dbf4af71] [127.0.0.1] Started GET "/assets/forms.css?body=1" for 127.0.0.1 at 2013-01-18 19:39:22 -0500
[708c81464666f10e1b2a46e1dbf4af71] [127.0.0.1] Served asset /forms.css - 304 Not Modified (2ms)
[3a807660584a753319c6c19c405b9cce] [127.0.0.1]
[3a807660584a753319c6c19c405b9cce] [127.0.0.1]
I do like knowing what's loading, but isn't there a way to clean these empty messages up a little?

There is a gem, but I don't recall the name... just put this into config/initializers/quiet_assets.rb
Rails.application.assets.logger = Logger.new('/dev/null')
Rails::Rack::Logger.class_eval do
def before_dispatch_with_quiet_assets(env)
before_dispatch_without_quiet_assets(env) unless env['PATH_INFO'].index("/assets/") == 0
end
alias_method_chain :before_dispatch, :quiet_assets
end

Related

Why does ActionCable continually try to upgrade a connection when it can't find a logged in user

Rails 5.2.1
Routes:
Rails.application.routes.draw do
mount ActionCable.server => '/cable'
.
.
.
I have the following code in app/channels/application_cable/connection.rb
module ApplicationCable
class Connection < ActionCable::Connection::Base
identified_by :current_user
def connect
self.current_user = find_verified_user
end
private
def find_verified_user
if verified_user = env['warden'].user
verified_user
else
logger.add_tags 'ActionCable', "The user is not found. Connection rejected."
reject_unauthorized_connection
end
end
end
end
I noticed that when I don't have a logged in user the server logs look as follows:
Started GET "/cable" for 127.0.0.1 at 2018-12-21 14:37:05 +0700
Started GET "/cable/" [WebSocket] for 127.0.0.1 at 2018-12-21 14:37:05 +0700
Successfully upgraded to WebSocket (REQUEST_METHOD: GET, HTTP_CONNECTION: Upgrade, HTTP_UPGRADE: websocket)
[ActionCable] [The user is not found. Connection rejected.] An unauthorized connection attempt was rejected
[ActionCable] [The user is not found. Connection rejected.] Failed to upgrade to WebSocket (REQUEST_METHOD: GET, HTTP_CONNECTION: Upgrade, HTTP_UPGRADE: websocket)
[ActionCable] [The user is not found. Connection rejected.] Finished "/cable/" [WebSocket] for 127.0.0.1 at 2018-12-21 14:37:05 +0700
[ActionCable] [The user is not found. Connection rejected.] Finished "/cable/" [WebSocket] for 127.0.0.1 at 2018-12-21 14:37:05 +0700
Started GET "/cable" for 127.0.0.1 at 2018-12-21 14:37:27 +0700
Started GET "/cable/" [WebSocket] for 127.0.0.1 at 2018-12-21 14:37:27 +0700
Successfully upgraded to WebSocket (REQUEST_METHOD: GET, HTTP_CONNECTION: Upgrade, HTTP_UPGRADE: websocket)
[ActionCable] [The user is not found. Connection rejected.] An unauthorized connection attempt was rejected
[ActionCable] [The user is not found. Connection rejected.] Failed to upgrade to WebSocket (REQUEST_METHOD: GET, HTTP_CONNECTION: Upgrade, HTTP_UPGRADE: websocket)
[ActionCable] [The user is not found. Connection rejected.] Finished "/cable/" [WebSocket] for 127.0.0.1 at 2018-12-21 14:37:27 +0700
[ActionCable] [The user is not found. Connection rejected.] Finished "/cable/" [WebSocket] for 127.0.0.1 at 2018-12-21 14:37:27 +0700
Started GET "/cable" for 127.0.0.1 at 2018-12-21 14:37:49 +0700
Started GET "/cable/" [WebSocket] for 127.0.0.1 at 2018-12-21 14:37:49 +0700
Successfully upgraded to WebSocket (REQUEST_METHOD: GET, HTTP_CONNECTION: Upgrade, HTTP_UPGRADE: websocket)
[ActionCable] [The user is not found. Connection rejected.] An unauthorized connection attempt was rejected
[ActionCable] [The user is not found. Connection rejected.] Failed to upgrade to WebSocket (REQUEST_METHOD: GET, HTTP_CONNECTION: Upgrade, HTTP_UPGRADE: websocket)
[ActionCable] [The user is not found. Connection rejected.] Finished "/cable/" [WebSocket] for 127.0.0.1 at 2018-12-21 14:37:49 +0700
[ActionCable] [The user is not found. Connection rejected.] Finished "/cable/" [WebSocket] for 127.0.0.1 at 2018-12-21 14:37:49 +0700
Started GET "/cable" for 127.0.0.1 at 2018-12-21 14:38:11 +0700
Is it correct and the normal behavior of ActionCable to continually attempt to make a connection until if finds a logged in user?
AFAIK, the upgrade isn't because of a not logged in user. I believe this is a function of the WS(S) connection attempting a handshake via HTTP(S) and then upgrading itself.
This is a behavior of your web server layer (Puma, Apache, etc.), and not your application layer (Rails, Sinatra, etc.).

gitlab error: Could not authorize you from LDAP because "Invalid credentials" when trying to sign into UI via LDAP/AD

My LDAP configuration located at /etc/gitlab/gitlab.rb is as follows:
gitlab_rails['ldap_enabled'] = true
gitlab_rails['ldap_servers'] = YAML.load <<-'EOS'
main: # 'main' is the GitLab 'provider ID' of this LDAP server
label: 'LDAP'
host: '10.3.32.11'
port: 389
uid: 'sAMAccountName'
bind_dn: 'CN=svc gitlab,CN=Users,DC=VPN,DC=Local'
password: 'PASSWORD'
encryption: 'plain' # "start_tls" or "simple_tls" or "plain"
verify_certificates: false
active_directory: true
allow_username_or_email_login: true
lowercase_usernames: true
block_auto_created_users: false
base: 'ou=vpnusers,dc=vpn,dc=local'
user_filter: '(&(objectCategory=user)(memberOf=CN=appGitLab,ou=vpnusers,dc=vpn,dc=local))'
EOS
I have ran a gitlab-ctl reconfigure and gitlab-ctl restart aftewr these configuration changes.
EDIT:
my production.log output is as follows:
Completed 200 OK in 3ms (Views: 0.4ms | ActiveRecord: 0.0ms | Elasticsearch: 0.0ms)
Started POST "/users/auth/ldapmain/callback" for 10.88.0.189 at 2018-08-21 12:57:56 -0500
Processing by OmniauthCallbacksController#failure as HTML
Parameters: {"utf8"=>"✓", "authenticity_token"=>"[FILTERED]", "username"=>"aaron.west", "password"=>"[FILTERED]"}
Redirected to http://10.3.18.80/users/sign_in
Completed 302 Found in 279ms (ActiveRecord: 1.8ms | Elasticsearch: 0.0ms)
Started GET "/users/sign_in" for 10.88.0.189 at 2018-08-21 12:57:56 -0500
Processing by SessionsController#new as HTML
Completed 200 OK in 35ms (Views: 18.9ms | ActiveRecord: 2.4ms | Elasticsearch: 0.0ms)
Started GET "/-/metrics" for 127.0.0.1 at 2018-08-21 12:57:58 -0500
Processing by MetricsController#index as HTML
Completed 200 OK in 3ms (Views: 0.4ms | ActiveRecord: 0.0ms | Elasticsearch: 0.0ms)
Started GET "/-/metrics" for 127.0.0.1 at 2018-08-21 12:58:13 -0500
Processing by MetricsController#index as HTML
Any idea why I keep seeing Could not authorize you from LDAP because "Invalid credentials" upon LDAP login?
There is a task you can check if your LDAP configuration is okay and get some samples of possible LDAP users: LDAP Rake Tasks
The LDAP check Rake task will test the bind_dn and password credentials (if configured) and will list a sample of LDAP users. This task is also executed as part of the gitlab:check task, but can run independently using the command below.
Omnibus Installation
sudo gitlab-rake gitlab:ldap:check
Source Installation
sudo -u git -H bundle exec rake gitlab:ldap:check RAILS_ENV=production
By default, the task will return a sample of 100 LDAP users. Change this limit by passing a number to the check task:
rake gitlab:ldap:check[50]

Realm Object Servers "Token expired warnings" normal?

After running the Realm Object Server for a few days with 1k users I find a lot of "Token expired" warnings in the logs like the following:
...
info: [http] 174.214.2.XXX - POST /auth HTTP/1.1 200 912 - 44.937 ms
info: [http] 127.0.0.1 - GET /realms/files/XXXXXXXXXXXXXXXX HTTP/1.1 200 73 - 19.172 ms
error: [sync] Sync Connection[41887]: Session[2]: Token expired (signed_user_token='...+1RFAMxHDevcmAl1ywSAAWnGS39w==').
error: [sync] Sync Connection[41887]: Session[2]: Token expired (message_type='bind', signed_user_token='...+1RFAMxHDevcmAl1ywSAAWnGS39w==').
info: [http] 174.214.2.XXX - POST /auth HTTP/1.1 200 912 - 48.745 ms
info: [http] 127.0.0.1 - GET /realms/files/XXXXXXXXXXXXXXXX HTTP/1.1 200 43 - 7.368 ms
...
Is that normal? Is it save to ignore? because I don´t see a "Connection closed" or "terminated" error after these?

Error connecting to Redis on localhost:6379 (Errno::ECONNREFUSED)

I'm trying to make edits to certain pages on our website on localhost:3000 but am experiencing the following error on specific pages.
Redis::CannotConnectError in FeaturesController#inventory
Error connecting to Redis on localhost:6379 (Errno::ECONNREFUSED)
ENV dump:
GATEWAY_INTERFACE: "CGI/1.2"
HTTP_ACCEPT: "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8"
HTTP_ACCEPT_ENCODING: "gzip, deflate, sdch"
HTTP_ACCEPT_LANGUAGE: "en-US,en;q=0.8"
HTTP_CACHE_CONTROL: "max-age=0"
REMOTE_ADDR: "127.0.0.1"
SERVER_NAME: "localhost"
SERVER_PROTOCOL: "HTTP/1.1"
In development.log file, it says:
Started GET "/en/ipad-pos-for-retail/inventory-management" for 127.0.0.1 at 2016-10-05 17:02:22 -0400
Processing by FeaturesController#inventory as HTML
Parameters: {"locale"=>"en"}
Geokit is using the domain: localhost
Completed 500 Internal Server Error in 709ms
Redis::CannotConnectError (Error connecting to Redis on localhost:6379 (Errno::ECONNREFUSED)):
app/controllers/features_controller.rb:46:in `inventory'
Rendered /Users/benedictwong/.rvm/gems/ruby-2.2.5/gems/actionpack-3.2.13/lib/action_dispatch/middleware/templates/rescues/_trace.erb (10.4ms)
Rendered /Users/benedictwong/.rvm/gems/ruby-2.2.5/gems/actionpack-3.2.13/lib/action_dispatch/middleware/templates/rescues/_request_and_response.erb (2.4ms)
Rendered /Users/benedictwong/.rvm/gems/ruby-2.2.5/gems/actionpack-3.2.13/lib/action_dispatch/middleware/templates/rescues/diagnostics.erb within rescues/layout (45.1ms)
Would really appreciate some help! Complete newbie here!

After updating to Rails 3.1.0.rc5 Passenger with nginx has intermittent 502 errors

It appears that only one passenger instance serves requests, the others just serve 502 errors. This causes an intermittent error pattern because only the requests that are directed to the second instance fail.
~$ rvmsudo passenger-status
----------- General information -----------
max = 4
count = 2
active = 0
inactive = 2
Waiting on global queue: 0
----------- Application groups -----------
/u/apps/pixie.strd6.com/current:
App root: /u/apps/pixie.strd6.com/current
* PID: 3179 Sessions: 0 Processed: 121 Uptime: 3m 57s
* PID: 3762 Sessions: 0 Processed: 0 Uptime: 2s
This happened after updating to Rails 3.1.0 rc5
2011/07/27 21:37:37 [error] 3125#0: *608 upstream prematurely closed connection while reading response header from upstream, client: 68.226.71.148, server: pixieengine.com, request: "GET /chats/recent HTTP/1.1", upstream: "passenger:unix:/passenger_helper_server:", host: "pixieengine.com", referrer: "http://pixieengine.com/projects/426/ide"
2011/07/27 21:38:31 [error] 3125#0: *596 upstream prematurely closed connection while reading response header from upstream, client: 76.102.14.57, server: pixieengine.com, request: "GET /chats/recent HTTP/1.1", upstream: "passenger:unix:/passenger_helper_server:", host: "pixieengine.com", referrer: "http://pixieengine.com/pixel-editor"
2011/07/27 21:39:12 [error] 3125#0: *576 upstream prematurely closed connection while reading response header from upstream, client: 68.8.173.234, server: pixieengine.com, request: "GET /chats/recent HTTP/1.1", upstream: "passenger:unix:/passenger_helper_server:", host: "pixieengine.com", referrer: "http://pixieengine.com/community/forums/1"
2011/07/27 21:39:12 [error] 3125#0: *687 upstream prematurely closed connection while reading response header from upstream, client: 201.231.103.247, server: pixieengine.com, request: "GET /chats/active_users HTTP/1.1", upstream: "passenger:unix:/passenger_helper_server:", host: "pixieengine.com", referrer: "http://pixieengine.com/projects/demo/ide"
2011/07/27 21:39:12 [error] 3125#0: *686 upstream prematurely closed connection while reading response header from upstream, client: 201.231.103.247, server: pixieengine.com, request: "GET /chats/recent HTTP/1.1", upstream: "passenger:unix:/passenger_helper_server:", host: "pixieengine.com", referrer: "http://pixieengine.com/projects/demo/ide"
I solved this by switching to Unicorn.
I wasn't actually able to figure out how to fix passenger, but I was able to verify that it broke because of the transition from Rails 3.0.9 to 3.1.0.rc5.
The temporary fix is to use PassengerSpawnMethod conservative in passenger, which disables forking running processes.