My application is returning 502 error:
In the error.log:
2017/10/12 15:42:28 [error] 12727#12727: *415 connect() to unix:/var/www/autonomos/production/current/tmp/sockets/unicorn.sock failed (111: Connection refused) while connecting to upstream, client: 172.31.81.4, server: api.autonomosapp.com.br, request: "GET /v1/auth/validate_token HTTP/1.1", upstream: "http://unix:/var/www/autonomos/production/current/tmp/sockets/unicorn.sock:/v1/auth/validate_token", host: "api.autonomosapp.com.br"
My nginx/sites-enabled
upstream unicorn_autonomos_production {
server unix:/var/www/autonomos/production/current/tmp/sockets/unicorn.sock fail_timeout=0;
}
server {
listen 80;
#listen 443 ssl;
server_name api.autonomosapp.com.br;
root /var/www/autonomos/production/current/public;
access_log /var/www/autonomos/production/shared/log/access.log;
error_log /var/www/autonomos/production/shared/log/error.log;
client_max_body_size 500M;
keepalive_timeout 5;
gzip_types application/x-javascript text/css;
location /elb-status {
return 200;
}
location ~ /.well-known {
allow all;
root /var/www/autonomos/production/current/public;
}
location ~* ^/assets/ {
# Per RFC2616 - 1 year maximum expiry
# http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html
expires 1y;
add_header Cache-Control public;
# Some browsers still send conditional-GET requests if there's a
# Last-Modified header or an ETag header even if they haven't
# reached the expiry date sent in the Expires header.
add_header Last-Modified "";
add_header ETag "";
break;
}
location / {
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $http_host;
proxy_redirect off;
if (!-f $request_filename) {
proxy_pass http://unicorn_autonomos_production;
break;
}
}
error_page 500 502 503 504 /500.html;
location = /500.html {
root /var/www/autonomos/production/current/public;
}
}
nginx/nginx.conf
user www-data;
worker_processes auto;
pid /run/nginx.pid;
events {
worker_connections 768;
# multi_accept on;
}
http {
##
# Basic Settings
##
sendfile on;
tcp_nopush on;
tcp_nodelay on;
keepalive_timeout 65;
types_hash_max_size 2048;
# server_tokens off;
# server_names_hash_bucket_size 64;
# server_name_in_redirect off;
include /etc/nginx/mime.types;
default_type application/octet-stream;
##
# SSL Settings
##
ssl_protocols TLSv1 TLSv1.1 TLSv1.2; # Dropping SSLv3, ref: POODLE
ssl_prefer_server_ciphers on;
##
# Logging Settings
##
access_log /var/log/nginx/access.log;
error_log /var/log/nginx/error.log;
##
# Gzip Settings
##
gzip on;
gzip_disable "msie6";
# gzip_vary on;
# gzip_proxied any;
# gzip_comp_level 6;
# gzip_buffers 16 8k;
# gzip_http_version 1.1;
# gzip_types text/plain text/css application/json application/javascript text/xml application/xml application/xml+rss text/javascript;
##
# Virtual Host Configs
##
include /etc/nginx/conf.d/*.conf;
include /etc/nginx/sites-enabled/*;
}
My etc/init/unicorn_autonomos_production
start on runlevel [2]
stop on runlevel [016]
console owner
setuid autonomos
pre-start exec /usr/local/rvm/bin/autonomos_production_unicorn_rails -E production -c /var/www/autonomos/production/current/config/unicorn.rb -D > /tmp/upstart_autonomos_production.log 2>&1
post-stop exec kill `cat /var/www/autonomos/production/current/tmp/pids/unicorn.pid`
respawn
unicorn.stderr.log
I, [2017-10-10T04:24:00.952787 #2245] INFO -- : reaped #<Process::Status: pid 2248 exit 0> worker=0
I, [2017-10-10T04:24:00.952946 #2245] INFO -- : master complete
My unicorn_autonomos_production not in init.d, it is a problem?
When I try:
service unicorn_autonomos_production start
The error is:
Failed to start unicorn_autonomos_production.service: Unit unicorn_autonomos_production.service not found.
I reload the nginx server today, I needed to initialize the unicorn too? How can I do?