标签:socket star moni ali gre config gen ash error_log
RAILS_ENV=production rake secret /etc/profile export SECRET_KEY_BASE=刚才生成的密钥 source /etc/profile
这种简单的把端口暴露出去, 可能出现服务得不到应答的问题,tcp被各种close_wait阻塞。解决的办法:架设nginx。
rails 的web服务主要有puma, unicorn, passenger
threads_count = ENV.fetch("RAILS_MAX_THREADS") { 5 } threads threads_count, threads_count environment ENV.fetch("RAILS_ENV") { "prodution" } daemonize trueworkers 2 application_path = "/home/apphome" worker_timeout 60 stdout_redirect "#{application_path}/shared/log/puma.stdout.log" state_path "#{application_path}/shared/tmp/sockets/puma.state" pidfile "#{application_path}/shared/tmp/pids/puma.pid" bind "unix://#{application_path}/shared/sockets/app.sock" activate_control_app "unix://#{application_path}/shared/sockets/pumactl.sock" # directory "#{application_path}/current" preload_app!
# 通过ps -aux| grep 查看一下是否启动,如果没有启动成功,把daemonzie注释掉,就能看到报错信息。
/etc/nginx/nginx.conf
# For more information on configuration, see: # * Official English Documentation: http://nginx.org/en/docs/ # * Official Russian Documentation: http://nginx.org/ru/docs/ user nginx; worker_processes auto; error_log /var/log/nginx/error.log; pid /run/nginx.pid; # Load dynamic modules. See /usr/share/nginx/README.dynamic. include /usr/share/nginx/modules/*.conf; events { worker_connections 1024; } http { log_format main ‘$remote_addr - $remote_user [$time_local] "$request" ‘ ‘$status $body_bytes_sent "$http_referer" ‘ ‘"$http_user_agent" "$http_x_forwarded_for"‘; access_log /var/log/nginx/access.log main; sendfile on; tcp_nopush on; tcp_nodelay on; keepalive_timeout 65; types_hash_max_size 2048; include /etc/nginx/mime.types; default_type application/octet-stream; include /etc/nginx/conf.d/*.conf; upstream app { server unix://home/上面puma文件中填的bind路径.sock; } server { listen 4000 default_server; server_name 123.207.68.151; root app的根目录; # Load configuration files for the default server block. include /etc/nginx/default.d/*.conf; location / { proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header Host $http_host; proxy_set_header X-Real_IP $remote_addr; proxy_redirect off; proxy_pass http://app; # 这里填写upstream的名称
} keepalive_timeout 10; error_page 404 /404.html; location = /40x.html { } error_page 500 502 503 504 /50x.html; location = /50x.html { } } }
重启nginx: systemctl restart nginx
标签:socket star moni ali gre config gen ash error_log
原文地址:https://www.cnblogs.com/yxi-liu/p/10331310.html