我的Rails应用程序在我的本地开发环境(Mac)中运行良好。我将代码推送到测试服务器,并尝试手动启动它,但出现错误。详细信息是:
OS: Ubuntu 18.04
Rails 5.2.3
Ruby 2.6.3
Puma
Webpacker
Nginx
我的/etc/nginx/sites-enabled/myfqdn.com.conf文件:
upstream puma {
server unix:///home/test/shared/tmp/sockets/test-puma.sock;
}
server {
listen 80 default_server deferred;
server_name test.xxxxxx.com;
root /home/amptest/public;
access_log /home/test/log/nginx.access.log;
error_log /home/test/log/nginx.error.log info;
location ^~ /assets/ {
gzip_static on;
expires max;
add_header Cache-Control public;
}
try_files $uri/index.html $uri @puma;
location @puma {
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $http_host;
proxy_redirect off;
proxy_pass http://puma;
}
error_page 500 502 503 504 /500.html;
client_max_body_size 10M;
keepalive_timeout 10;
}
我创建了目录:
/home/myapp/shared
/home/myapp/shared/tmp
/home/myapp/shared/tmp/sockets
/home/myapp/shared/tmp/pids
我的config / puma.rb文件如下:
threads_count = ENV.fetch("RAILS_MAX_THREADS") { 5 }
threads threads_count, threads_count
port ENV.fetch("PORT") { 3000 }
environment ENV.fetch("RAILS_ENV") { "development" }
plugin :tmp_restart
在我的.bashrc中,我有:
export RAILS_ENV='test'
在我的Gemfile中,我有:
gem 'puma'
gem 'webpacker'
我跑了
bundle install
没有错误
成功进行了数据库迁移:
rake db:migrate
并播种数据库:
rake db:seed
然后我做了:
bundle exec rake assets:precompile
正确完成的操作
bundle exec rake assets:precompile
2019-09-10 01:36:10 WARN Selenium [DEPRECATION] Selenium::WebDriver::Chrome#driver_path= is deprecated. Use Selenium::WebDriver::Chrome::Service#driver_path= instead.
yarn install v1.17.3
[1/4] Resolving packages...
success Already up-to-date.
Done in 0.76s.
I, [2019-09-10T01:36:13.413669 #3461] INFO -- : Writing /home/myapp/public/assets/express/lib/application-9232ebdb20ad39572e70fb9e29810e63dbb63b58f5f18617c7c2bc8bd28321b5.js
I, [2019-09-10T01:36:13.413941 #3461] INFO -- : Writing /home/myapp/public/assets/express/lib/application-9232ebdb20ad39572e70fb9e29810e63dbb63b58f5f18617c7c2bc8bd28321b5.js.gz
Compiling…
Compiled all packs in /home/test/public/packs-test
但是我尝试去test.xxxxxx.com,却收到错误消息“东西错了”。
nginx错误日志显示:
2019/09/10 05:38:21 [crit] 1192#1192: *1 connect() to unix:///home/test/shared/tmp/sockets/test-puma.sock failed (2: No such file or directory) while connecting to upstream, client: xx.xxx.xxx.xxxx, server: test.xxxxxx.com, request: "GET / HTTP/1.1", upstream: "http://unix:///home/test/shared/tmp/sockets/test-puma.sock:/", host: "test.xxxxxx.com"
2019/09/10 05:38:47 [info] 1192#1192: *3 client closed connection while waiting for request, client: xx.xxx.xxx.xxxx, server: 0.0.0.0:80
因此,我缺少一个或更多个步骤,包括确保Puma正确启动所需的操作。有什么想法吗?