3

When I deploy with Capistrano 3 I deploy to /home/dev/app-name/. Cap creates a directory structure /home/dev/app-name/current/

which is a symlink to /home/dev/app-name/releases/20181129161818 (the current release).

This symlink is broken and does not work for nginx and passenger. I know this because this is my app config located in /etc/nginx/conf.d/app-name.conf:

server {
  listen 80;
  server_name app-name.domain.com;

  passenger_enabled on;
  passenger_ruby /home/dev/.rvm/gems/ruby-2.5.1/wrappers/ruby;

    rails_env production;

    root /home/dev/app/app-name/releases/20181129161818/public/;
    #root /home/dev/app/app-name/current/public;
}

if I comment out the path root /home/dev/app/mullen-admin/releases/20181129161818/public/; and sudo service nginx restart the app works.

If I use the other root directive, the app is broken and I get this 500 Server Error.

2018/11/29 15:31:43 [alert] 11278#0: *3 Cannot stat '/home/dev/app/app-name/current/passenger_wsgi.py': 
Permission denied (errno=13); This error means that the Nginx worker process (PID 11278, running as UID 1002) does not have permission to access this file. 
Please read this page to learn how to fix this problem: https://www.phusionpassenger.com/library/admin/nginx/troubleshooting/?a=upon-accessing-the-web-app-nginx-reports-a-permission-denied-error; 
Extra info, client: 10.194.234.100, server: app-name.domain.com, request: "GET /employees/sign_in HTTP/1.1", host: "app-name.domain.com"

I am running centos-release-7-5.1804.5.el7.centos.x86_64 on a virtual machine at the office I work at. I have a sudouser dev that I use to ssh and deploy with.

Please help!? I need the app to work at /current in the nginx root directive so I can deploy and have changes take effect.

Jaffa
  • 12,442
  • 4
  • 49
  • 101
PDev
  • 410
  • 4
  • 10
  • If I remember correctly, capistrano sets up a specific folder for `public`, so it's not in the release itself, it shoud be `/home/dev/app/app-name/public` or something similar – Jaffa Dec 03 '18 at 14:21
  • shared/public is where capistrano rails/assets puts compiled assets. So unfortunately that is not the solution. – PDev Dec 03 '18 at 18:46
  • https://stackoverflow.com/a/15263923/1122270? – cnst Dec 10 '18 at 06:54

1 Answers1

1

I assume capistrano has already symlink directive: ln -nfs release_path current_path

Cannot stat '/home/dev/app/app-name/current/passenger_wsgi.py': 
Permission denied (errno=13);

Your symlink is not broken, your permissions are and you must align them (passenger does not have permission to create file). Change the chmod after deploy:symlink

Something like

 run "#{try_sudo} chmod 755 -R #{current_path}"

Also depending on your config you might want for example to execute chown instead of sudo

dfens
  • 5,413
  • 4
  • 35
  • 50