ReSTARTR / nginx-unit-sample

Home Page:https://medium.com/@restartr/nginx-unit-build-and-run-app-servers-58c522188c99

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Nginx UNIT sample

NOTE: This repository depends on the repository http://github.com/ReSTARTR/unit that is forked from https://github.com/nginx/unit

Build Nginx Unit from source

Install dependencies(ref: https://github.com/nginx/unit#precompiled-packages).

Build unitd control server

$ go get github.com/ReSTARTR/unit # or git-clone
$ cd github.com/ReSTARTR/unit
$ git checkout go-include-path
$ ./configure && make

Run unitd

$ ./build/unitd --control unix:/tmp/control.unit.sock

Prepare for each app server

for lang in php python go; do
  ./configure $lang && make $lang
done

Build Go Server

$ cd ./go_server
$ go build -o go_server

Edit listeners.json for your environment.

# If you run on Mac, with "-i ''" option
$ sed -E "s:GOPATH:$GOPATH:g" ./listeners.json

Notify to unit control server.

$ cd github.com/ReSTARTR/unit
$ curl --unix /tmp/control.unit.sock -XPUT -d @./listeners.json http://localhost/

and request to the application server

$ for port in 8200 8300 8400; do curl localhost:$port; echo; done
Hello, PHP
Hello, Python
Hello, Go

About

https://medium.com/@restartr/nginx-unit-build-and-run-app-servers-58c522188c99


Languages

Language:Python 48.0%Language:Go 47.5%Language:PHP 4.6%