Do I need to restart NginX after reconfigure for passenger to work - ruby-on-rails

I just updated my NginX configuration.
In the config I've added a new server with a different environment for a rails application.
I've reloaded the configuration (sbin/nginx -s reload) and deployed the application to the right folder but nothing seems to happen, NginX throws 404 not found..
Is there anything more I need to do?
Do I need to restart NginX or passenger for example?

Turns out you don't need to restart.
Passenger isn't able to restart (as far as I've found out) and NginX only needs a reload.

Related

Deploying Rails/Passenger via nginx

I'm having a hard time figuring out where I'm going wrong in trying to deploy a Rails app via nginx. Rails is accessible via site.com:3000 (after starting it with rails server), and site.com:80 displays the standard nginx "working, but further configuration required" page. I've spent a few hours trawling the documentation trying to figure our how to get my Rails app accessible at :80 rather than :3000, but to no avail.
I think it's most likely that I'm misunderstanding how nginx, Passenger, and Rails work together, and have therefore configured my nginx.conf incorrectly (one page I found implied that I shouldn't both be using nginx and running rails server). Any and all help is hugely appreciated.
Possibly relevant version numbers:
Rails 4.1.4
Ruby 2.1.2p95
CentOS 6.5
nginx 1.6.0
nginx.conf partial: http://pastebin.com/A3JD09pr
I'm new at this, so it turned out that a couple things were up:
I needed to put export rvmsudo_secure_path=1 in my .bashrc instead of just running it once, following up with source ~/.bashrc in the terminal. This allowed me to run "rvmsudo" commands to start on port 80 rather than the default 3000.
I had both nginx and Rails competing for port 80, so I had to stop nginx's static page server to allow that. Simple as nginx stop.

Restart only a single Rails app running on Passenger / nginx on VPS hosting many passenger apps

I am running multiple rails apps and a sinatra app under the same domain on a VPS using nginx and passenger. When I deploy code I need to restart the application process for the app that got updated. Right now I'm running service nginx stop followed by service nginx start thereby restarting all the passenger processes. It seems silly to have to restart nginx instead of a just the target passenger process. Is there a way to do such a thing?
Here's my nginx.conf file: https://gist.github.com/srt32/8535548. Thanks.
Goto the root of your Rails application and touch a tmp/restart.txt file.
touch /webapps/mycook/tmp/restart.txt
Remove restart.txt once application is restarted, not mandatory though.
Reference - http://www.modrails.com/documentation/Users%20guide%20Nginx.html#_redeploying_restarting_the_ruby_on_rails_application

Why it won't apply changes when using Nginx?

I've just switched from Apache + Passenger to Nginx + Unicorn
I used to command /etc/init.d/httpd restart after I added change.
Then all the changes used to be applied to Rails Application.
But with Nginx, even if I command service nginx restart, changes won't be applied:(
Why? and How can I fix this problem?
You need to restart unicorn itself. See http://unicorn.bogomips.org/SIGNALS.html
With Apache+Passenger, when you restart Apache, it restarts Passenger. Unicorn is it's own server however and needs to be restarted/reloaded itself.

Deploying Rails applications with Passenger and Nginx to VPS (EC2)

I've developed a couple of applications which I'm ready to deploy. To do so, I've configured Capistrano and I'm already able to run cap deploy, which runs properly. However, I'm totally lost as to how to continue from here. My setup is EC2 + Rails 3.2 + Ruby 1.9.3 + Passenger + Nginx (the one Passenger installs first time you try to start it) + Capistrano.
Until now, I just ran passenger start on my app root folder, which would start passenger on port 3000, and I would start the second app on port 3001. Now, what I need is to have this 2 apps under 2 different domains, say www.domain1.com and www.domain2.com.
How am I supposed to start the servers now? I can go to the respective current folders that Capistrano created and run something like passenger start -e production -p 3001 -d and it starts running as a daemon, but, shouldn't capistrano take care of this? All I see is that, on each deploy, it touches the restart.txt file and that forces a "soft restart", which is not enough (as far as I know) if you've changed gems. Shouldn't Capistrano be starting and stopping Passenger, not me?
How do I run the 2 apps on 2 domains? As far as I know, you can't point a domain to a port, and all I've managed to do now is to run 1 of the applications by running Passenger on port 80 with rvmsudo, but of course this only works for 1 application. After searching a bit I've found something about Nginx Virtual Servers. How do you do this? I mean, I have never touched anything specific to Nginx, just Passenger! Am I supposed to forget about Passenger and deal with Nginx as a service? How?
Thanks in advance!
I believe to start servers there's a specific cap command to start servers, but i don't know much about capistrano, just played with it a little bit before.
As for the second part, this is where nginx takes part, nginx will handle forwarding each domain to the specific port, using proxy_pass, take a look at this example
server {
server_name: example1.com;
proxy_pass: http://127.0.0.1:3000;
}
server {
server_name: example2.com;
proxy_pass: http://127.0.0.1:3001;
}

How do i make nginx and passenger restart automatically after a deploy

I currently have a rails app deployed on a virtual private server.
I use Capistrano, Nginx and passenger to run my rails app on the server.
For some reason I can never get the updated code to display on the site after i have done a cap deploy:update.
The deploy happens fine and the code is even seen on the live server via Vim but if I navigate to the live site it won't display.
My current workaround is rebooting the server, starting nginx and passenger after the server boots back up.
my concern is if someone is logged on to the site when i deploy and restart, it will knock them off the site.
Does anyone have any ideas
If you run touch tmp/restart.txt from your rails root directory, passenger will restart the app. You shouldn't have to restart nginx. After the timestamp of the restart.txt file changes, Passenger will restart for the next request. If your app takes a while to boot, you may want to force this by making a request immediately after touching the file.
You don't need to worry about kicking someone off the site, it won't restart the server if there is a request in process.
If you are still facing the problem you can use Monit gem, in capstraino it works really well.

Resources