Communication between unicorn and nginx -- [ruby unix socket], unicornnginx

Source: Internet
Author: User

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

 

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.