Communication between unicorn and nginx -- [ruby unix socket], unicornnginx
Article Source: [Chang Bo ke] http://www.xefan.com/archives/84146.html
Ruby application services are typically used together with a web service, such as nginx. When a user requests a page in your Rails application, nginx assigns the request to the application service.
But how is this process completed? How does nginx communicate with unicorn?
One of the most effective options is to use unix sockets (sockets ). Let's see how they work!
In this article, we will start with a basic socket (sockets) and finally create a simple application service using the nginx proxy.
Require "socket" server = UNIXServer. new ('/tmp/simple. sock ') puts "=== Waiting for connection" socket = server. accept puts "=== Got Request:" puts socket. readline puts "=== Sending Response" socket. write ("I read you both and clear, good buddy! ") Socket. close