Paul's Programming Notes     Archive     Feed     Github

Docker Run In Crontab

"0 5 * * 1 docker run --rm --name=mycontainer ubuntu:13.10 /opt/bin/job"
The above command is an example of how "docker run" would be used in crontab to run once every week at 5am.

  • --rm will delete the container once the job is finished running
  • --name will name the container and prevent duplicate jobs from running
  • You don't need to use "&" at the end, because crons already run in the background.

MySQL Batch Updates Not Working

Looking at "SHOW PROCESSLIST" and it looks like your queries are running individually instead of in batches like you sent?

This happens because MySQL runs each update statement individually, but you should still be able to see the batches when the queries are in the "init" state.

Use this query to see the batched queries:

mod_wsgi + Flask

Here’s my mod_wsgi configuration for a flask app that uses Flask-Admin.

Trailing slashes matter! If you set a trailing slash, it will only set the alias for that directory and not all of the directories below it.

Dokku Change Nginx Timeout

None of the plug-ins for doing custom nginx configurations were working for me.

So, I changed the following two files:

I added the following under "location    / {":
proxy_connect_timeout 300s;
proxy_read_timeout 300s;

Supervisord Tips and Gotchas

If you make configuration changes, the changes will not take effect until you:
  • supervisorctl reread
  • supervisorctl update

"redirect_stderr=true" will cause both stderr and stdout to appear in the "stdout" log.

You get to select which user runs the command with the "user" parameter.
For example: user=root
Supervisord keeps its own set of environmental variables with the "environment" parameter. It won't pick up env variables from /etc/environment.
For example: environment=A="1",B="2"
For Gunicorn, use a configuration file rather than putting all your arguments into the "command" parameter.
For example, -t will be ignored here:
command=/path/to/gunicorn main:application -t 300
Instead use:
command=/path/to/gunicorn main:application -c /path/to/