Custom Log Files With Django and Elastic Beanstalk

With Amazon ElasticBeanstalk it is possible to view log files of your deployed application. However, ElasticBeanstalk by default only returns certain logs like /var/log/httpd/error_log or /var/log/httpd/access_log if you are using Apache httpd.

If you are generating custom logs in your Django application and using file handlers to save them to log files, you will probably want to be able to access and read them easily from the ElasticBeanstalk console.

In this post I will show you how to achieve this, using Django as our backend framework.

django elasticbeanstalk

Making Functions Timeout in Python

Sometimes you need to execute a function that can take a lot of time to finish. You are not sure exactly when the function will finish, but you do not want to wait too long, or let your program “hang” waiting for a response.

We want our function to run for a certain period of time, and if this time limit is exceeded, we want to regain control of the program’s execution.

We can achieve this by using a custom context manager and the signal module from the Python standard library.

Here is a complete example:


Dropdown Toolbar Buttons in Netbeans Platform

It is possible to add buttons that toggle a dropdown menu to the main toolbar in your Netbeans Platform application.

For example, the Netbeans IDE Run Project, Debug Project, and Profile Project buttons have a small arrow next to them. When clicked, a dropdown menu with more related actions is shown:

Netbeans IDE Dropdown Buttons

In this article, I will teach you how to implement this behavior.

netbeans platform

Setting Up Elastic Beanstalk Health Checks With a Django Application

I was having an issue the past few days with Django and Elastic Beanstalk in a production environment that was driving me nuts.

Basically the Elastic Beanstalk environment was in a permament Severe/Degraded state. The health monitoring was reporting that 100% of the requests to the load balancer where 4xx requests:

Elastic Beanstalk 4xx requests

This issue was probably caused by several reasons. In this post I will go over the reasons I think I was experiencing it, and how it was fixed in the end.

django elasticbeanstalk

Media-Type Based Responses With Django REST Framework

Nowadays a typical REST API responds with data in JSON format. But what if you wanted to serve data in a different format (and not just a serialization format) using the same endpoint, but specified by the client?

Django REST Framework renderers can help us achieve this nice feature.

Use Case: ONIX For Books Compatible API

ONIX for books is an XML format for sharing bibliographic data pertaining to both traditional books and eBooks.

Let’s say our application serves metadata about books (title, author, etc.) in the usual JSON format, but we also want to provide data in ONIX format, which is an XML standard that defines how the metadata should be described and put together for consumption.

Older Posts →