I am new to AWS Beanstalk-Rails-Puma-Nginx.
After deploying my RAILS app to Beanstalk, all my api calls work fine, but HTML pages are causing error.
When opening my HTML page -
Nginx throws 502 Bad Gateway error.
Puma log :
Started GET "/admin" for 182.70.76.160 at 2016-04-22 05:13:19 +0000
Processing by Devise::SessionsController#new as HTML
Rendered devise/sessions/new.html.erb within layouts/application (6.1ms)
[18858] ! Terminating timed out worker: 22913
var/app/current/production.log is empty.
Read somewhere, that adding SSL could solve. Is it required to added SSL?
Please help! I am stuck!
STATUS :
My assets were huge because of which it was killing itself. I was using a theme and removed all the unnecessary js, css and images.
Now, Puma doesn't terminate, but it doesnot compile assets. I had selected Ruby as application type so it should do it for me, correct?
Try setting worker timeout to a higher value in puma config. Default value is 60 seconds
worker_timeout 100
It is possible that you are creating more workers than the server could handle. Try decreasing the worker count or increasing the server capacity.
For now I moved to EC2 as EBS issues weren't getting solved.
I had the same issue on EC2 but I could fix it as I access my machine.
Puma workers were timing out because my assets weren't precompiled.
Everytime I take a new build on server, I have to run the following :
RAILS_ENV=production rake assets:precompile
Related
I have a Rails (puma) app with webpacker (webpack). I'm doing split chunking on ~40 of my pages at the routing level. When I run the app locally my requests start to slow down (see img below) after about an hour of running the server. I'm not sure why. If I kill my rails server and/or webpack dev server and restart them it still continues to be slow (If I restart my machine it'll go back to being fast. haha).
Any ideas how to fix or debug this?
// rails console output for this page:
#method=GET path=/invite format=html controller=HomeController action=index status=200 duration=154.88 view=154.15 db=0.00
Firstly, cheers! This is my first post here on Stack Overflow, I'll try not to do anything silly :). I've spent the last 3 days banging my head against this issue and googleing away, but never really found a solution, however basic it may be.
I've set up a fresh EC2 instance (running Ubuntu 16.04) and created a new Rails (v 5.1.6) app with a simple scaffold:
rails new test_app
cd test_app
At this point, Rails complained that I had to install the 'listen' gem, which I did (v 3.1.5). I then proceeded as follows:
rails g scaffold article title:string
rails db:create
rails db:migrate
So far so good. I then went on to configure AWS's security groups and properly allow TCP connections through port 3000. I'm currently using Puma (v 3.7) as a server.
Here's whats bugging me: I then ran
rails server
and tried to connect to my EC2 through Chrome on port 3000. Turns out that I was able to get to the usual "You're on Rails" page, no problem, but when I tried to get to any other pages, say /articles or /articles/new, I got a positive response from the server in the console:
Started GET "/articles"
Processing by ArticlesController#index as HTML
Rendering articles/index.html.erb within layouts/application
Article Load (0.7ms) SELECT "articles".* FROM "articles"
Rendered articles/index.html.erb within layouts/application (47.3ms)
Completed 200 OK in 3912ms (Views: 3807.5ms | ActiveRecord: 1.5ms)
But the browser keeps waiting forever for a response. I also tried accessing the URL through curl and got no response as well. I'd appreciate if anyone could let me know how stupid a mistake I'm making here.
Thanks,
Márcio
Firstly, cheers you explained your problem very well
when you deploying your app on EC2 then this isn't the right way to do but still it should give you response in browser. Please make sure your port 3000 isn't blocked. Go to network interface -> select your instance carefully -> in front of Security groups check your inbound rules and make sure port 3000 is open
Above explanation is just to answer whatever you are trying to do. Although this should not be the proper way. Proper way should (in short ) be running your ruby on rails application with a rack server (puma, thin, etc) behind a web server Apache or Nginx .
Since this afternoon, access to the backend of my spree shop is suddenly unavailable. When I try to visit any page in the backend (/admin/users, /admin/orders, etc) the page just loads for a long time, until it times out and I get the generic error page.
When I look into the logs I always see either :
Processing by Spree::Admin::OrdersController#index as HTML
Completed 500 Internal Server Error in 127259ms
** [Airbrake] Success: Net::HTTPOK
Errno::ETIMEDOUT (Connection timed out - connect(2)):
app/middleware/flash_session_cookie_middleware.rb:18:in `call'
or
Processing by Spree::Admin::OrdersController#index as HTML
Completed 500 Internal Server Error in 127520ms
** [Airbrake] Success: Net::HTTPOK
SocketError (getaddrinfo: Name or service not known):
app/middleware/flash_session_cookie_middleware.rb:17:in `call'
This started happening after the last deployment to production, which only changed images and stylesheets. I can't reproduce the error locally, despite having the same code and an exact copy of the production database.
I'm using Spree version 2.0.3
Run Spree::Config[:check_for_spree_alerts] = false in your console to fix this. You may also want to add this line to your initializers/spree.rb to ensure check_for_spree_alerts is not re-enabled in the future.
This is happening because the Spree Alerts website has been discontinued. See: https://github.com/spree/spree/pull/6516
To be specific, this is happening because when logging into the backend, Spree 2.0.x checks for any alerts from the Spree website here https://github.com/spree/spree/blob/2-0-stable/backend/app/controllers/spree/admin/base_controller.rb#L39 which then calls alert.rb:14 :
HTTParty.get('http://alerts.spreecommerce.com/alerts.json', query: params).parsed_response
At the moment, alerts.spreecommerce.com has been discontinued and is timing out, which explains the errors you're receiving.
The Spree Alerts code has been removed as of Spree 2.3, so you could also upgrade to that version to resolve this issue.
People keeps claiming that my website always hang out at some pages. I checked the unicorn stderr log, and found many timeout errors like:
E, [2013-08-14T09:27:32.236478 #30027] ERROR -- : worker=5 PID:11619 timeout (601s > 600s), killing
E, [2013-08-14T09:27:32.252252 #30027] ERROR -- : reaped #<Process::Status: pid=11619,signaled(SIGKILL=9)> worker=5
I, [2013-08-14T09:27:32.266141 #4720] INFO -- : worker=5 ready
There are many error messages like that.
Then I go to the rails production log, find the exact requests by searching the unicorn error time minus 601s. These timeout request, all choked at the page rendering phase. The sql of these requests are done already. It just never gets an end:
Processing by XXXController#index as HTML
Rendered xxx/index.html.erb within layouts/application (41.4ms)
Rendered shared/_sidebar.html.erb (200.9ms)
No complete. Most of these requests served successfully. I don't know why at random time, it hang out there.
I have no idea what may cause this. Can anybody give me a clue of how to find the real reason that cause the unicorn workers to timeout?
Update:
We used NSC to transfer request and response to unicorn. And to try to improve the timeout issue, we added nginx between NSC and unicorn. It turns out the unicorn worker timeout still happens, and each timeout matches a nginx upstream timeout in nginx error log.
Does anyone knows whether there is some kind of bottle neck in TCP connection of unicorn?
I'm using Rack::Timeout to time out before unicorn. Unicorn timeout uses kill -9, and I don't think that gives you any way to do anything.
Need some help here.
I have deployed spree (0.70.3) on slicehost (ubuntu, ruby1.8.7, Rails
3.1.3), installed the spree gem, loaded in the sample data
successfully following the steps on spree startup manual and I am
using passenger (it works on localhost:3000). When I upload to my
server, however, instead of seeing the spree interface, I am getting
an error message. From the production.log:
Processing by HomeController#index as HTML Completed 500 Internal
Server Error in 22ms ActiveRecord::StatementInvalid (Could not find
table 'product_groups'):
Any suggestions how I can get this to work?
Website: http://www.nutxboutique.com
production.log is the rails log. It appears your problem is occurring before rails completes loading. If you're using apache, check/post the apache logs, it might have more clues as to what's going on.