Re: [capistrano] After successful deployment app not running on production server (RoR/Capistrano/Github)

506 views
Skip to first unread message

Lee Hambley

unread,
May 14, 2013, 7:52:31 AM5/14/13
to capistrano
Hi Mathias,

Probably you forgot to configure a virtual host for your nginx installation.



On 14 May 2013 13:25, Makru <makr...@gmail.com> wrote:
Hello,

i am new to all related Ruby and Ruby on Rails and just started some weeks ago learning with tutorials and books.

Following one capistrano deployment tutorial, everything looks fine but the RoR application is not running.

CAP DEPLOY works according the Windows cmd-window but opening the webpage via a browser results in the:

Welcome aboard You’re riding Ruby on Rails!

-window, which is ok but if i go to the application, i get a 404 error from nginx.


I checked that Unicorn and NGINX are running on the Debian server. A restart does not help.

My enviroment :

  • Development Windows 7
  • Production Debian 6 with nginx and Unicorn
  • Ruby and Rails newest via RVM on Debian and Railsinstaller on Windows
  • Deployment using capistrano & github & SSH

Because i can not see a error during deployment i would be interested to know how to troubleshoot?

Many thanks in advance.

Best Regards

Mathias



--
--
* You received this message because you are subscribed to the Google Groups "Capistrano" group.
* To post to this group, send email to capis...@googlegroups.com
* To unsubscribe from this group, send email to capistrano+...@googlegroups.com For more options, visit this group at http://groups.google.com/group/capistrano?hl=en
---
You received this message because you are subscribed to the Google Groups "Capistrano" group.
To unsubscribe from this group and stop receiving emails from it, send an email to capistrano+...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

Makru

unread,
May 14, 2013, 8:43:51 AM5/14/13
to capis...@googlegroups.com
Hello Lee,

thanks for your hint. Please have a look at:

https://gist.github.com/Makru/5575568

This is my nginx.conf file, named blog.conf which is stored under

/etc/nginx/conf.d/blog.conf  on the production server. Is there something missing?

I am wondering about line 7 as comment:


  # server_name example.com;

Something else missing or wrong?

Regards
Mathias

Lee Hambley

unread,
May 14, 2013, 9:28:15 AM5/14/13
to capistrano
Sorry Mathias,

This is the wrong place to get nginx support, I'd try #nginx on Freenode's IRC network.

(it's a time thing, perhaps someone else on the list can help you)

Makru

unread,
May 14, 2013, 9:41:42 AM5/14/13
to capis...@googlegroups.com
Hello again,

nginxis running and showing the rails welcome page. Only the application and the link at the Rails welcome page called

About your application’s environment

are not reachable and showing only:

404 Not Found

nginx/1.4.0

Thats why i am not sure, where the problem is....

Regards

Mathias

Hassan Schroeder

unread,
May 14, 2013, 9:55:08 AM5/14/13
to capis...@googlegroups.com
On Tue, May 14, 2013 at 4:25 AM, Makru <makr...@gmail.com> wrote:
>
> I checked that Unicorn and NGINX are running on the Debian server. A restart
> does not help.

> Because i can not see a error during deployment i would be interested to
> know how to troubleshoot?

Look at the nginx/unicorn/rails logs on the server. Try starting up
a console. Try connecting to unicorn directly from the server itself.

Troubleshooting 101.
--
Hassan Schroeder ------------------------ hassan.s...@gmail.com
http://about.me/hassanschroeder
twitter: @hassan

Donovan Bray

unread,
May 14, 2013, 11:41:45 AM5/14/13
to capis...@googlegroups.com
This isn't likely to be a capistrano issue. 

Shut nginx and unicorn down on the server. 

Make sure you've made provisions for doing all of the configuration required for RAILS_ENV=production and ensure you are launching unicorn with RAILS_ENV=production 

Verify you can run a 

rails console production 

From the <deploy_to>/current directory where your app is deployed. 

Start nginx and unicorn back up manually. Recheck your app. 

On May 14, 2013, at 4:25 AM, Makru <makr...@gmail.com> wrote:

Hello,

i am new to all related Ruby and Ruby on Rails and just started some weeks ago learning with tutorials and books.

Following one capistrano deployment tutorial, everything looks fine but the RoR application is not running.

CAP DEPLOY works according the Windows cmd-window but opening the webpage via a browser results in the:

Welcome aboard You’re riding Ruby on Rails!

-window, which is ok but if i go to the application, i get a 404 error from nginx.


I checked that Unicorn and NGINX are running on the Debian server. A restart does not help.

My enviroment :

  • Development Windows 7
  • Production Debian 6 with nginx and Unicorn
  • Ruby and Rails newest via RVM on Debian and Railsinstaller on Windows
  • Deployment using capistrano & github & SSH

Because i can not see a error during deployment i would be interested to know how to troubleshoot?

Many thanks in advance.

Donovan Bray

unread,
May 14, 2013, 11:47:38 AM5/14/13
to capis...@googlegroups.com
Post a gist of your unicorn.rb

Make sure your unix sockets are pointing to the same place. 

Your nginx is pointing to /tmp/...

I'd hazzard a bet your unicorn.rb is pointing to the rails root tmp and not the root tmp dir. 

Donovan Bray

unread,
May 14, 2013, 11:49:22 AM5/14/13
to capis...@googlegroups.com
Does the app work in development mode locally?

Makru

unread,
May 14, 2013, 5:05:57 PM5/14/13
to capis...@googlegroups.com
Hello,

thanks for the answers. Learned a lot through the discussion :-)

Here is the unicorn.rb : https://gist.github.com/Makru/5579322
The only pointing i can see is : pid APP_PATH + "/tmp/pids/unicorn.pid"

The small test application is running on the Windows development PC.

I am able to open a Raisl Console in the current folder on the server.

The strange thing is, the console opens with :
"Loading production enviroment (Rails 3.2.13)
1.9.1 :001> "

I have ruby 1.9.3p392 installed on the server and development pc. ruby -v is showing that. Should it not the same version in the rails console ? The rails version is like installed.

production.log looks ok, no error
unicorn.blog.stderr.log shows no error
I can not find a nginx log.

This is the deploy.rb : https://gist.github.com/Makru/5579470 Perhaps this helps...

Hassan Schroeder

unread,
May 14, 2013, 5:25:56 PM5/14/13
to capis...@googlegroups.com
On Tue, May 14, 2013 at 2:05 PM, Makru <makr...@gmail.com> wrote:

> I am able to open a Raisl Console in the current folder on the server.

And successfully access your app? Do AR finds, etc.?

> The strange thing is, the console opens with :
> "Loading production enviroment (Rails 3.2.13)
> 1.9.1 :001> "
> I have ruby 1.9.3p392 installed on the server and development pc. ruby -v is
> showing that. Should it not the same version in the rails console ?

I would guess the ruby you're using is not the one you think...

> I can not find a nginx log.

The location is specified in your nginx config file.

Makru

unread,
May 14, 2013, 6:54:36 PM5/14/13
to capis...@googlegroups.com
Post.find (:all)
answers:
Post Load (1.2ms) ....
=>nil
Is working under development and showing all entries. I assume under production the table is there, but no entry.
app.get 'posts/new'
answers:
=>200
Same answer as under development.
But the good thing, i know now something about rails console :-)

Hassan Schroeder

unread,
May 14, 2013, 7:06:03 PM5/14/13
to capis...@googlegroups.com
On Tue, May 14, 2013 at 3:54 PM, Makru <makr...@gmail.com> wrote:
> Post.find (:all)
> answers:
> Post Load (1.2ms) ....
> =>nil
> Is working under development and showing all entries. I assume under
> production the table is there, but no entry.
> app.get 'posts/new'
> answers:
> =>200
> Same answer as under development.
> But the good thing, i know now something about rails console :-)

OK, so your app apparently is basically working. But (restating) if
you try to access /posts/new from a browser you get a 404, right?

What happens if you access the unicorn instance directly, from the
server command line?

If the above works, then the problem is somewhere between nginx
and unicorn; you should find your nginx log(s) and see what happens
at that point.

I would open up 3-4 windows side-by-side and tail -f the nginx
access, error, and unicorn log(s) -- don't remember if it has both
access and error logs -- and watch in real time.

Donovan Bray

unread,
May 14, 2013, 10:39:58 PM5/14/13
to capis...@googlegroups.com
Looks like your socket paths match up

listen "/tmp/unicorn.blog.sock", :backlog => 64
listen 8080, :tcp_nopush => true

You don't need the 8080 listener though it doesn't hurt anything.

Do you have rvm installed on the server? If you do you have to sort that out first. You may be starting it without rvm loaded and going to the system ruby.

How do you start unicorn?

Donovan Bray

unread,
May 14, 2013, 10:43:56 PM5/14/13
to capis...@googlegroups.com
Ensure that there is only one nginx config since you are using port 80 and no server_names defined. Ie remove the default conf in sites-enabled

Makru

unread,
May 18, 2013, 9:44:44 AM5/18/13
to capis...@googlegroups.com
Hello again,

found the nginx error log. 
If i try to access the application the following error is added:

2013/05/18 14:55:02 [error] 5307#0: *5 open() "/var/www/blog/current/public/posts" failed (2: No such file or directory), client: 46.126.103.174, server: , request: "GET /posts HTTP/1.1", host: "www.mysite"

And the access to 

About your application’s environment shows:

2013/05/18 15:42:23 [error] 5307#0: *11 open() "/var/www/blog/current/public/rails/info/properties" failed (2: No such file or directory), client: 46.126.103.174, server: , request: "GET /rails/info/properties HTTP/1.1", host: "hb9dou.ch", referrer: "http://mysite//"

 

Looking for nginx.conf  shows it on 3 different folders:
nginx: /usr/sbin/nginx  /etc/nginx  /usr/share/nginx

But i edited the nginx.conf called new blog.conf is in the conf.d folder. Should i delete all other? The sites-enabled folder is only under /etc/apache2/. I think this was installed by default.

If i try to access port localhost:8080 in the browser it answers : 

The page you were looking for doesn't exist.

Is this the right way to connect Unicorn direct?

Yes i use rvm as it was described in the tutorial but i have no idea how to change to not use it
Regards
Mathias
Reply all
Reply to author
Forward
0 new messages