Mastodon

oooops.dev

DevOps is hard

File Limits and how the “Too many open files” error can pop up unexpectedly — January 17, 2021

File Limits and how the “Too many open files” error can pop up unexpectedly

I have recently come across a nasty Too many open files error, and noticed the information on the internet about what that might mean or how to solve it doesn’t always paint a clear picture.

Here I try to put together a more complete guide by gathering all the resources I found as I was dealing with the issue myself.

What are file limits and file descriptors?

In Unix-like systems, each process is associated with sets of usage limits, which specify the amount of system
resources they can use. One of those is the limit of open file descriptors (RLIMIT_NOFILE).

But what is a file descriptor?

Continue reading
One line Bash HTTP Server — January 16, 2021

One line Bash HTTP Server

Here is a quick snippet I use all the time when I want to set up an HTTP server on the fly, without leaving the comfort of my terminal.

This is the command:

$ while true; do { echo -e 'HTTP/1.1 200 OK\r\n'; echo "Hello World"} | nc -l 3000; done

Warning: this will block your current terminal.

You will see the following output as you receive requests:

GET / HTTP/1.1
Host: localhost:3000
User-Agent: curl/7.54.0
Accept: */*

If you want your terminal back, or for any other reason want to put the command in the background while it is running, simply press ctrl+z.

When you are done and want to kill the background process, you can do so with

$ kill %1
Super Quick Node.js HTTP Server —