2015-05-20 19 views
11

Ho appena distribuito un'applicazione Rails su Elastic Beanstalk e ogni richiesta mi ha generato un errore 502.Applicazione Rails distribuita su Elastic Beanstalk con Puma non riuscita - 502 errori su ogni richiesta

Ecco il contenuto della /var/logs/nginx/error.log

2015/05/20 16:24:25 [warn] 1535#0: conflicting server name "localhost" on 0.0.0.0:80, ignored 
2015/05/20 16:27:12 [crit] 1537#0: *20 connect() to unix:///var/run/puma/my_app.sock failed (2: No such file or directory) while connecting to upstream, client: 172.31.51.94, server: _, request: "POST /get HTTP/1.1", upstream: "http://unix:///var/run/puma/my_app.sock:/get", host: "securities-api-prod.elasticbeanstalk.com" 
2015/05/20 16:27:17 [crit] 1537#0: *20 connect() to unix:///var/run/puma/my_app.sock failed (2: No such file or directory) while connecting to upstream, client: 172.31.51.94, server: _, request: "POST /get HTTP/1.1", upstream: "http://unix:///var/run/puma/my_app.sock:/get", host: "securities-api-prod.elasticbeanstalk.com" 
2015/05/20 16:27:19 [crit] 1537#0: *20 connect() to unix:///var/run/puma/my_app.sock failed (2: No such file or directory) while connecting to upstream, client: 172.31.51.94, server: _, request: "POST /get HTTP/1.1", upstream: "http://unix:///var/run/puma/my_app.sock:/get", host: "securities-api-prod.elasticbeanstalk.com" 
2015/05/20 16:27:22 [crit] 1537#0: *16 connect() to unix:///var/run/puma/my_app.sock failed (2: No such file or directory) while connecting to upstream, client: 172.31.44.210, server: _, request: "GET /datapoint?tickers=AAPL&datapoints=Ratings HTTP/1.1", upstream: "http://unix:///var/run/puma/my_app.sock:/datapoint?tickers=AAPL&datapoints=Ratings", host: "securities-api-prod.elasticbeanstalk.com" 
2015/05/20 16:27:27 [crit] 1537#0: *20 connect() to unix:///var/run/puma/my_app.sock failed (2: No such file or directory) while connecting to upstream, client: 172.31.51.94, server: _, request: "POST /get HTTP/1.1", upstream: "http://unix:///var/run/puma/my_app.sock:/get", host: "securities-api-prod.elasticbeanstalk.com" 
2015/05/20 16:27:32 [crit] 1537#0: *20 connect() to unix:///var/run/puma/my_app.sock failed (2: No such file or directory) while connecting to upstream, client: 172.31.51.94, server: _, request: "POST /get HTTP/1.1", upstream: "http://unix:///var/run/puma/my_app.sock:/get", host: "securities-api-prod.elasticbeanstalk.com" 
2015/05/20 16:28:53 [crit] 1537#0: *52 connect() to unix:///var/run/puma/my_app.sock failed (2: No such file or directory) while connecting to upstream, client: 172.31.51.94, server: _, request: "GET /datapoint?tickers=AAPL&datapoints=Ratings HTTP/1.1", upstream: "http://unix:///var/run/puma/my_app.sock:/datapoint?tickers=AAPL&datapoints=Ratings", host: "securities-api-prod.elasticbeanstalk.com" 
2015/05/20 16:30:47 [crit] 1537#0: *69 connect() to unix:///var/run/puma/my_app.sock failed (2: No such file or directory) while connecting to upstream, client: 172.31.51.94, server: _, request: "POST /get HTTP/1.1", upstream: "http://unix:///var/run/puma/my_app.sock:/get", host: "securities-api-prod.elasticbeanstalk.com" 

Penso puma è in esecuzione -

[[email protected] nginx]$ ps aux | grep puma 
root  23299 1.0 0.2 53008 1428 ?  Ss 16:38 0:00 su -s /bin/bash -c puma -C /opt/elasticbeanstalk/support/conf/pumaconf.rb webapp 
webapp 23314 0.0 2.4 75764 14604 ?  Rsl 16:38 0:00 /opt/rubies/ruby-2.1.4/bin/ruby /opt/rubies/ruby-2.1.4/bin/puma -C /opt/elasticbeanstalk/support/conf/pumaconf.rb 
ec2-user 23317 0.0 0.1 110284 844 pts/0 S+ 16:38 0:00 grep puma 

pumaconf.rb

directory '/var/app/current' 
threads 8, 32 
workers %x(grep -c processor /proc/cpuinfo) 
bind 'unix:///var/run/puma/my_app.sock' 
stdout_redirect '/var/log/puma/puma.log', '/var/log/puma/puma.log', true 
daemonize false 

Qualcuno sa cosa sta succedendo?

+0

per favore, fornire il vostro pumaconf.rb sembra che nginx cerchi file socket puma inesistenti –

+0

@StanislavMekhonoshin Aggiunto! – chintanparikh

+0

Sto riscontrando un problema simile. Hai trovato una soluzione a questo? – Disha

risposta

0

Questa riga nel file di registro indica che il tuo nginx non è stato configurato correttamente.

upstream: "http://unix:///var/run/puma/my_app.sock:/get" 

In realtà nginx tenta di utilizzare un socket di dominio unix come URL HTTP.

Non posso dire esattamente ciò che è sbagliato a vostra configurazione nginx senza di essa, ma si dovrebbe avere qualcosa di simile:

upstream backend { 
    server backend1.example.com weight=5; 
    server 127.0.0.1:8080  max_fails=3 fail_timeout=30s; 
    server unix:/tmp/backend3; 

    server backup1.example.com backup; 
} 

Si dovrebbe anche verificare questo nginx doc http://nginx.org/en/docs/http/ngx_http_upstream_module.html

+1

Qualche idea su dove si trova la configurazione di nginx? – chintanparikh

+0

Non ho esperienza con EBS, ma di solito nginx config si trova in/etc/nginx/sites-enabled/* Ma proverei a cambiare 'bind 'unix: /// var/run/puma/my_app.sock'' to 'bind 'tcp: //0.0.0.0: 8080'' per esempio. Sarebbe molto più semplice –

0

Il dottore AWS impone l'installazione di puma gem come parte della tua applicazione.

Aggiungere il seguente al vostro Gemfile a seconda dei casi:

group :production do 
    gem 'puma' 
end 
+0

Ricevo ancora l'errore [http://stackoverflow.com/questions/37472304/rails-elastic-beanstalk-connection-time-out-puma-server). Sembra che la richiesta prima di andare a nginx prima di puma nei timestamp. Non so come risolvere questo problema –

6

Ho affrontato lo stesso errore e l'aggiunta di queste due righe alla config/puma.rb risolto il problema:

bind "unix:///var/run/puma/my_app.sock" 
pidfile "/var/run/puma/my_app.sock" 

Dopo questo passo ho affrontato un altro errore per aggiungere valori ENV, che è molto semplice.

Spero che questo aiuti.

Problemi correlati