Skip to content

Instantly share code, notes, and snippets.

View danmackinlay's full-sized avatar

dan mackinlay danmackinlay

View GitHub Profile
@danmackinlay
danmackinlay / mysql_logger.lua
Created August 27, 2009 09:17
quick little script for mysql_proxy's lua interpreter to show you when queies start and end so you can see if some are timing out. helps if you don't have control of the server
local log_file = 'mysql.log'
local fh = io.open(log_file, "a+")
function read_query( packet )
if string.byte(packet) == proxy.COM_QUERY then
local query = string.sub(packet, 2)
local q = query
local cutoff = 160
if cutoff < #query then
q = query:sub(1, cutoff) .. "..."
@danmackinlay
danmackinlay / supervisord.ini
Created August 27, 2009 07:10
a supervisord minimal config for running e.g. a persistent process queue.
[program:queuewalker]
command = /project_path/manage.py process_queue
redirect_stderr = true
user=www-data
umask=002
[supervisord]
logfile = /var/log/supervisord.log
logfile_maxbytes = 50MB
logfile_backups=10
@danmackinlay
danmackinlay / supervisord.sh
Created August 27, 2009 07:07
an init.d script for supervisord
#! /bin/sh
### BEGIN INIT INFO
# Provides: supervisord
# Required-Start: $remote_fs
# Required-Stop: $remote_fs
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Example initscript
# Description: This file should be used to construct scripts to be
# placed in /etc/init.d.
@danmackinlay
danmackinlay / lock.py
Created August 27, 2009 02:04
django- or FS-based contextmanager-friendly locks for python
"""
various ways of acquiring cross-process locks on a string including a django one
http://www.evanfosmark.com/2009/01/cross-platform-file-locking-support-in-python/
needs test coverage, but won't get it here since I've just removed it from the project.
`with` statement requires python 2.5 or later; these may work as non-with statement doohickeys
django locks require version 1.0 or later to get the "force_insert" argument
"""
@danmackinlay
danmackinlay / prowl_monitor.py
Created August 26, 2009 04:05
load-monitoring script that pushes notifications to prowl when something goes wrong
#!/usr/bin/env python
"""
load-monitoring script that pushes notifications to growl when something goes wrong
requires jacobb's prowlpy http://github.com/jacobb/prowlpy/tree/master - and a prowl
account (http://prowl.weks.net/)
this version, with a "panic" function, is untested.
"""