Skip to main content

A brief look into nginx unit

So nginx has come out with it's own application server that can run multiple types of application from PHP, Python and Go, with more languages support coming soon. Deployment is always my topic of interest so this kind of news definitely caught my eyes.

There's not much technical information yet, other than the official blog post. I'm quite interested to know how the python support being implemented. The Application model also remind me to the Webfaction hosting model and with unit HTTP API, it provide possibility to implement something like Webfaction hosting panel where you can add new application and manage it all through just a web interface.

Reading through the source code of python module support, it look like python wsgi application is being executed in-process through python C API (my guess), particularly if you look at the line 337:-

result = PyObject_CallObject(nxt_py_application, args);

For Go application however it simply execute the Go built-in http server and communicate through that. The current implementation is merely 100 lines compared to python implementation which is almost 1000 lines.

Enough with all the theories, I decided to give it a try. It has deb packages for Ubuntu Xenial. Just follow the documentation how to install it through apt. The docs however seem missing on how to start unit after installing it. After scouring around the apt file then I know the binary is named as unitd, so to start it:-

sudo systemctl start unitd

After that you can start communicating with unitd through the HTTP JSON API:-

sudo curl --unix-socket /var/run/control.unit.sock http://localhost/

Btw, it also through this I learned that curl has unix socket support !

For the rest, you can just follow the docs. I did try with simple wsgi applications and discovered few issues:-
  • https://github.com/nginx/unit/issues/17 - How to apply changes to our app script ?
  • https://github.com/nginx/unit/issues/16 - All applications and listeners lost after restarting unitd
  • https://github.com/nginx/unit/issues/12 - How to inject environment variables ?
  • https://github.com/nginx/unit/issues/15 - How to add venv packages ?
That's all for now. Next probably trying it from source instead of packages to get all the latest changes.

Comments

Popular posts from this blog

PHP with docker

A friend asking about a PHP library and I decided to test whether that library is working. But I don't have PHP environment setup (we're Python shop btw). But thanks to docker, that's easy these days. docker run -it --tty --rm --volume $PWD:/app --user $(id -u):$(id -g) composer require google/apiclient:^2.0 Then we just need to create the script to run, still in the same directory:- include_once __DIR__ . '/vendor/autoload.php'; $GCSE_API_KEY = "nqwkoigrhe893utnih_gibberish_q2ihrgu9qjnr"; $GCSE_SEARCH_ENGINE_ID = "937592689593725455:msi299dkne4de"; $client = new Google_Client(); $client->setApplicationName("My_App"); $client->setDeveloperKey($GCSE_API_KEY); $service = new Google_Service_Customsearch($client); $optParams = array("cx"=>self::GCSE_SEARCH_ENGINE_ID); $results = $service->cse->listCse("lol cats", $optParams); And we can run that script again using docker:- docker run -it --...

The first step in learning new programming language

Is to prepare the basic environment where you can freely try and experiment with the new language features and tools. Maybe because I'm not programmer type person, but more as tinkerer/builder, I hate learning the language syntax and stuff. For years after I started "learning" Python, I can't barely write any Python code. But I have manage to try lot of Python cool apps because I have that environment for me to experiment with all Python based applications. All these cool apps that get me hooked to the language, not the syntax or whatever language features. And in my experiences, this is one reason why people failed to get hooked on the new language they want to learn. They started learning with some of the language syntax and eventually get bored, because not so much interesting stuff there. In whatever programming language, it's the ecosystem that made it lively, and where the real work happened. Early this year, I made it a point to learn Go programmin...

AI coding tools fragmentation

Executive Summary The discussion centers on a tweet by DHH (David Heinemeier Hansson) from January 10, 2026 , arguing against the fragmentation of AI coding tools. DHH contends that developers do not want a separate CLI for every model provider (e.g., Anthropic’s Claude Code, OpenAI’s tools). Instead, he advocates for a unified interface —specifically citing OpenCode —that allows developers to swap models within a single environment. The thread reveals a three-way tension in the developer community between convenience (unified tools), corporate control (walled gardens), and sovereignty (running local models). Key Discussion Themes 1. The Fatigue of Fragmentation The Problem: Developers are exhausted by "model choice fatigue" and the need to manage multiple CLIs. As Rob Zolkos noted, the fragmentation is absurd, leading some to write scripts just to manage their AI CLIs. The Desire: There is a strong consensus (DHH, Will McGugan, Mustafa Ergisi) that a "universal s...