Puma not creating socket at defined location when started with `rails server`
Are you sure you are running Puma with that configuration? I don't think rails server
is the proper way to start Puma in a production environment.
I would use this instead:
RACK_ENV=production bundle exec puma -C config/puma.rb
Once you get this working manually, then use the --daemon
flag to keep the server running in the background.
Also, where is shared_dir
defined in your config/puma.rb
? Perhaps you omitted the part of the file, but if not, make sure you insert the correct value.
user2490003
Updated on July 04, 2022Comments
-
user2490003 almost 2 years
I'm deploying my Rails app using nginx, puma, and capistrano. It's deployed by a user called
deploy
and the deploy location is under the home directory (/home/deploy
)I have Puma configured to create a socket under the
shared
folder that Capistrano symlinks all it's releases to. Correspondingly, nginx is configured to look at that socket as well (see config files below)However when I start up the Rails / Puma webserver -
cd /home/deploy/my_app/current SECRET_KEY_BASE=.... DATABASE_PASSWORD=... rails s -e production
I notice that no socket file is created. When I visit the site in my browser and then look at the Nginx error log, it is also complaining about that socket not existing.
2016/07/17 14:26:19 [crit] 26055#26055: *12 connect() to unix:/home/deploy/my_app/shared/tmp/sockets/puma.sock failed (2: No such file or directory) while connecting to upstream, client: XX.YY.XX.YY, server: localhost, request: "GET http://testp4.pospr.waw.pl/testproxy.php HTTP/1.1", upstream: "http://unix:/home/deploy/my_app/shared/tmp/sockets/puma.sock:/500.html", host: "testp4.pospr.waw.pl"
How do I go about getting puma to create that socket?
Thanks!
Puma Config
# config/puma.rb ... # `shared_dir` is the symlinked `shared/` directory created # by Capistrano - `/home/deploy/my_app/shared` # Set up socket location bind "unix://#{shared_dir}/tmp/sockets/puma.sock" # Logging stdout_redirect "#{shared_dir}/log/puma.stdout.log", "#{shared_dir}/log/puma.stderr.log", true # Set master PID and state locations pidfile "#{shared_dir}/tmp/pids/puma.pid" state_path "#{shared_dir}/tmp/pids/puma.state" activate_control_app ...
Nginx sites config
# /etc/nginx/sites-available/default upstream app { # Path to Puma SOCK file server unix:/home/deploy/my_app/shared/tmp/sockets/puma.sock fail_timeout=0; } server { listen 80; server_name localhost; root /home/deploy/my_app/public; try_files $uri/index.html $uri @app; location @app { proxy_pass http://app; 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; }
-
user2490003 almost 8 yearsYou were absolutely right. I needed to start it with the
puma
command directly. For some reason I assumed requiring the puma gem would make rails default to using puma as the main server, and sorails server
would call puma. Rookie mistake I guess - thanks!