Blog / Devops

How to delete files older than x hours in Ubuntu

November 5, 2016

One of my apps, YouTube Audio Downloader, has been gaining quite a bit of traffic lately. It's a website that lets you convert YouTube videos to MP3/M4A audio. The conversion happens completely on my server and a download link is provided to the user when finished. The files need to be stored temporarily on my server so the users can download them.

Initially, I just had a daily cron job that runs at ...

Automatically generating and renewing Let's Encrypt SSL certificates with the certbot client and Ansible

August 11, 2016

I just finished updating my ansible-django-stack project and added tasks to automatically issue a Let's Encrypt SSL certificate and set up a cron job to auto-renew the certificate.

We're now using it for all our Shopify apps which are built in Django. Let's Encrypt certificates are only valid for 90 days, so if you have a bunch of web apps like we do and have more planned in the future, automating this ...

Ansible playbook for provisioning a Jenkins CI server

May 27, 2016

I've finally decided to set up a Jenkins CI server for my Django projects earlier this week. For a long time, I've been deploying code via command line with Ansible. It worked very well but occasionally I find myself deploying from a coffee shop with unreliable connection, causing the deployment to get interrupted. Deploying instead from a virtual private server in the cloud would solve this and using Jenkins to do it was ...

Using Amazon SQS with Django and Celery

August 31, 2015

I'm currently working on a new Django project which relies heavily on Celery. I normally use RabbitMQ for these kinds of projects but I decided to give Amazon SQS a try this time as it's very cheap and will simplify my setup.

While the Celery docs does a pretty good job explaining how to set it up, there were a few things that it didn't cover that I'm sure other devs ...

Using ipdb with Docker Compose for interactive debugging

May 30, 2015

Back in the early days of Docker Compose, when it was still called Fig, you couldn't use ipdb with it to do interactive debugging because the container's service ports weren't exposed when using the run command. This has been fixed by including a ---service-ports option to the docker-compose run command.

Below is a sample usage for one of my Django projects, EZ Price Alerts.

In my detail view, I added import ipdb ...

Using Docker and Docker Compose for local Django development (replacing virtualenv)

April 30, 2015

Before Docker came along, virtualenv was pretty much the tool of choice for Python developers as it allows you to separate package dependencies for different applications you're working on without having to create separate virtual machines for each one. It worked very well for me.

However, there are still some annoying things the developers will have to deal with. Such things include having to install additional applications and services required by the project such ...

Haystack with Solr: Indexing Tips

January 22, 2015

I was troubleshooting an issue a couple of weeks ago with some of our Django views taking too long to return a response. The issue was due to post_save and post_delete signals making a request to Solr to update the index with the 'commit' parameter set to 'true' (Haystack default). This basically tells Solr to do the indexing right away (hard commit) and it was taking a few seconds to finish.

Below are some tips ...