如何解决主服务器无法启动,请检查stderr日志以获取详细信息独角兽+ Nginx +铁路
我正在使用ruby 2.6.5开发Rails 6应用程序,并且尝试使用Unicorn和Nginx在lenode服务器上配置我的应用程序。 我关注了以下文章: https://www.linode.com/docs/guides/use-unicorn-and-nginx-on-ubuntu-14-04/
config / unicorn.rb
# set path to the application
app_dir = File.expand_path("../..",__FILE__)
shared_dir = "#{app_dir}/shared"
working_directory app_dir
# Set unicorn options
worker_processes 2
preload_app true
timeout 30
# Path for the Unicorn socket
listen "#{shared_dir}/sockets/unicorn.sock",:backlog => 64
# Set path for logging
stderr_path "#{shared_dir}/log/unicorn.stderr.log"
stdout_path "#{shared_dir}/log/unicorn.stdout.log"
# Set proccess id path
pid "#{shared_dir}/pids/unicorn.pid"
/etc/nginx/nginx.conf
user root;
worker_processes auto;
pid /run/nginx.pid;
include /etc/nginx/modules-enabled/*.conf;
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 TLSv1.3; # 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_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/*;
upstream rails {
# Path to Unicorn socket file
server unix:/home/myicourse/shared/sockets/unicorn.sock fail_timeout=0;
}
}
/ etc / nginx / sites-available / myicourse
server {
listen 80;
server_name localhost;
root /home/myicourse;
try_files $uri/index.html $uri @rails;
location @rails {
proxy_pass http://rails;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $http_host;
proxy_redirect off;
}
error_page 500 502 503 504 /500.html;
client_max_body_size 4G;
keepalive_timeout 10;
}
当我尝试使用命令sudo unicorn -c config/unicorn.rb -E production -D
启动独角兽时,它会抛出错误消息"master failed to start,check stderr log for details"
。
shared / log / unicorn.stderr.log
from config.ru:4:in `block in <main>'
from /usr/lib/ruby/vendor_ruby/rack/builder.rb:55:in `instance_eval'
from /usr/lib/ruby/vendor_ruby/rack/builder.rb:55:in `initialize'
from config.ru:1:in `new'
from config.ru:1:in `<main>'
from /usr/lib/ruby/vendor_ruby/unicorn.rb:54:in `eval'
from /usr/lib/ruby/vendor_ruby/unicorn.rb:54:in `block in builder'
from /usr/lib/ruby/vendor_ruby/unicorn/http_server.rb:794:in `build_app!'
from /usr/lib/ruby/vendor_ruby/unicorn/http_server.rb:141:in `start'
from /usr/bin/unicorn:128:in `<main>'
我在上述日志中没有得到任何正确的错误消息,并且在调试问题时,我还检查了Nginx日志并发现以下错误消息:-
/var/log/nginx/error.log
2020/10/25 18:14:38 [error] 278484#278484: *4 connect() to unix:/home/myicourse/shared/sockets/unicorn.sock failed (111: Connection refused) while connecting to upstream,client: 177.50.212.149,server: localhost,request: "GET / HTTP/1.1",upstream: "http://unix:/home/myicourse/shared/sockets/unicorn.sock:/500.html",host: "172.105.49.196:80"
您能指导我如何解决此问题吗?提前致谢。 PS:我正在使用root用户来配置应用程序。
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。