Thursday, September 14, 2017

Notes on AWS Lightsail

Finally, I'm trying Amazon Lightsail. Just few notes:-




1. The direct console is great. This is basically what EC2 should have, instead of web ssh console. You need this console to verify the ssh key fingerprint before connecting through ssh first time.
2. There's simple firewall manager. Only port 22 and 80 opened by default. Click Manage from the instance menu to get into the firewall manager.
3. Now there's apac region !

Friday, September 8, 2017

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.