0
votes

Didn't deployed Rails application in AWS OpsWorks. Totally confused how to do this! Could anyone tell me how many instance required to deploy a RoR application?

I have created "Rails App Server" instance and it's looks fine. And here I used nginx and Unicorn as Rails Stack.enter image description here

After that I've added a application from a git repo. Then deployed that application. And logs showing it's deployed successfully.

But in Public IP it's showing 404 Not Found Error - nginx!

Any help would be appreciable.

2

2 Answers

2
votes

I had this issue, and it turned out that the default virtual host /etc/nginx/sites-enabled/000-default symbolic link was not getting removed during deployment.

The 404 was actually nginx looking for a public root of whatever was in the default virtual host, as seen in /var/logs/nginx/error.log

2015/12/23 21:46:05 [error] 3839#0: *15 "/var/www/nginx-default/index.html" is not found (2: No such file or directory), client: 127.0.0.1, server: rails-app1, request: "GET / HTTP/1.1", host: "localhost"

Worse, it comes back after every OpsWorks deployment. Removing that link fixed the problem for me.

To make the fix sustainable and automated, I added a custom recipe to the Deploy lifecycle event for the Rails App Server layer, called custom-cookbook::delete-default-site. The recipe looks like this:

file '/etc/nginx/sites-enabled/000-default' do
    action :delete
end

service 'nginx' do
    action :reload
end
0
votes

Check process list for unicorn and its log files. Deployment doesn't fail for some reason if unicorn master process doesn't start.