#!/bin/bash
#
# Runs a command with database locking, to prevent multiple servers from
# running it at the same time. This command, lock-abort, will exit if the
# lock is already in use. See "lock-block" for the alternate mode.
#
# This also uses a lock file to prevent one server from accessing the database
# more than once for the same command. This only becomes an issue if the server
# or database server is running slowly, or if the command takes a long time.
#
# Usage: lock-abort python my-script.py
#

export RUN_LOCK_WAIT_MODE="nowait"

# Use an environment variable to avoid having the parameters mangled.
export RUN_LOCK_COMMAND="$*"

django-admin runlock
