Giter Site home page Giter Site logo

cocaine-native-proxy's Introduction

Cocaine Native Proxy

This proxy provides HTTP interface to a Cocaine cloud.

It selects an application and an event based on headers X-Cocaine-Service and X-Cocaine-Event or, if some of these headers are ommited, then based on URL (using format http://host/app/event...).

Building

Just run:

cmake -DCMAKE_BUILD_TYPE=RelWithDebInfo ./
make

You need Cocaine Native Framework, Cocaine development files and Swarm to build the proxy.

Usage

Run the proxy as follows:

cocaine-native-proxy -c <config>

Or if you use init-script from debian/ folder then just place your config to /etc/cocaine-native-proxy/ and restart the proxy with command sudo service cocaine-native-proxy restart. Your config must have extension *.conf.

Example config

{
    "endpoints": [
        "0.0.0.0:8080"
    ],
    "daemon": {
        "monitor-port": 20000
    },
    "backlog": 2048,
    "threads": 2,
    "application": {
        "locators": ["127.0.0.1:10053"],
        "logging_prefix": "cocaine-proxy-01",
        "service_pool": 10,
        "reconnect_timeout": 180,
        "request_timeout": 5
    }
}
  • endpoints — endpoints on which the proxy will listen for requests.
  • monitor-port — the port to retrieve monitoring information. Just try the command echo i | nc 127.0.0.1 20000.
  • threads — how many threads the proxy will run to handle requests. The proxy will run the same number of threads to communicate with Cocaine cloud.
  • locators — just list of entrypoints to your cloud. Most time the proxy will use first locator in the list, but if it is dead then the proxy will use some other one.
  • The proxy will write logs to the locator with logging_prefix source name.
  • service_pool — how many connections the proxy will create to each application. I recomend to specify at least 3 connections to improve balancing and reduce impact of unstable network.
  • The proxy will reconnect each connection every reconnect_timeout seconds (to rebalance requests to new nodes for examle).
  • If an application doesn't reply on a request for request_timeout seconds then the proxy drops the request and replies with 504 code.

cocaine-native-proxy's People

Contributors

3hren avatar andrusha97 avatar noxiouz avatar shindo avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

cocaine-native-proxy's Issues

cocaine-native-proxy wan't serve requests

I install cocaine-native-proxy with following config:

$ cat /etc/cocaine-native-proxy/default.conf 
{ 
  "endpoints": [ 
    "0.0.0.0:8080" 
  ], 
  "backlog": 2048, 
  "threads": 2, 
  "application": { 
    "locators": ["192.168.50.204:10053"], // <-- My gateway node
    "service_pool": 5, 
    "reconnect_timeout": 180, 
    "request_timeout": 5 
  } 
}

When I start flask app from examples. It works. I can connect to it by Service('flask', host='192.168.50.204') from python scripts.

But when I try to connect by HTTP - I got error 500:

vagrant@front:~$ curl -v http://192.168.50.204:8080/flask/http/read 
* About to connect() to 192.168.50.204 port 8080 (#0) 
* Trying 192.168.50.204... connected 
> GET /flask/http/read HTTP/1.1 
> User-Agent: curl/7.22.0 (x86_64-pc-linux-gnu) libcurl/7.22.0 OpenSSL/1.0.1 zlib/1.2.3.4 libidn/1.23 librtmp/2.3 
> Host: 192.168.50.204:8080 
> Accept: */* 
> 
< HTTP/1.1 500 Internal Server Error 
< Content-Length: 0 
< Connection: Keep-Alive 
< 
* Connection #0 to host 192.168.50.204 left intact 
* Closing connection #0

... and got following from syslog on 192.168.50.204:

May 7 00:14:26 front cocaine[1054]: native-proxy: Internal error has occurred while processing event 'http' of application 'flask': Service manager no longer exists; code - 4.

Another two cents. When I use cocaine-tornado-proxy by cocaine-tool proxy start - all works fine.

Thank you in advance for your help

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.