V
V
Vyacheslav Alekseev2014-05-22 15:33:59
Nginx
Vyacheslav Alekseev, 2014-05-22 15:33:59

How to properly configure RVM, Thin and Nginx?

Hi friends!
I install Thin for the first time, I can't set it up all day.
There is a Debian 7 x64 server, installed Ruby via RVM and gems rails and thin, Nginx.
Thin starts up normally and works from the project folder with the command thin start
There is a line in the manual:
/usr/sbin/update-rc.d -f thin defaults
Which showed me an error:

update-rc.d: using dependency based boot sequencing
update-rc.d: warning: default stop runlevel arguments (0 1 6) do not match thin Default-Stop values (S 0 1 6)
insserv: warning: current stop runlevel(s) (0 1 6) of script `thin' overrides LSB defaults (0 1 6 S).

I ended up replacing "S 0 1 6" with "0 1 6" in /etc/init.d/thin. Please comment if I did it right?
And now the most delicious: something that I just do not understand.
The manual says
then start your Thin cluster like this:
thin start -s3 -p 5000

To connect to Nginx using UNIX domain sockets edit the upstream block in your nginx config file:
nginx.conf

upstream  backend {
   server   unix:/tmp/thin.0.sock;
   server   unix:/tmp/thin.1.sock;
   server   unix:/tmp/thin.2.sock;
}

What sense to me to do a cluster from 3kh servers? Does this mean that 3 servers are created here for 3 hosts in nginx? Or does thin just need 3 servers? Why port 5000? Is this a port for internal server work or will sites be accessible on ports 5001 5002 and 5003? Will such a configuration work with PHP? Nginx.conf is then shared by everyone.
Here are all the questions I couldn't google.
Sorry if I'm being overly stupid :)
Thanks!

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
Dimitriy, 2014-05-24
@AlexeevVyacheslav

1. Yes, there is nothing in one user mode thin service - about runlevel
2. It is understood that three servers are launched on one machine and serve requests from clients, in your case there are 3 of them. Used for load balancing, for example when one server is doing a "heavy" task and more requests are coming in from clients.
2.1 The port can be used any higher than 1024.
2.2 Thin servers, by default, will be available on the network with the address, if memory does not change, 0.0.0.0 (i.e. any), to bind to a specific address, you must run with the key -a , example thin -a 127.0.0.1
About upstream in the nginx config, just the same, it is used to create a pool for the purpose of load balancing, only you have Unix sockets in your settings, (running thin -S /tmp/thin.sock -s3)
About linking with php, you will need before setting up Nginx for a specific configuration, i.e. what will be the backend for php (apache.fastcgi), and what are the conditions for redirecting to this backend.
Something like this.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question