Package: lockr
LockRis an open source CLI tool which solves the problem of concurrency management for distributed applications in cloud, using Redis.In summary, it provides out of the box ability to use the well knownRedis Locking patternorRedlock AlgorithmRead morehereWhy LockR?Manage any application in the cloud:It is meant to be a very general purpose CLI tool, to provide applications with distributed locking mechanism, to prevent duplicate instances of the application running at the same timeUsable for all sorts of applications (Flask app, Spring boot app, Celery beat/worker etc.) if you want to prevent more than one instance of the app running at the same time.Extremely fault-tolerant:LockRis designed to be resilient to network errors, application problems and so on. So you only need to worry about your own application.Simple to use:LockRis very straightforward to use and maintainNo 3rd party dependencies:LockRhas been built entirely using in-built python libraries, not relying on any 3rd party libraries.SetupRedis Server:You need an up and running redis server (or redis cluster), as later you need to specify the hostname and port for the Redis ServerMinimum redis version:2.6.12Getting startedInstall withpippipinstalllockrYou then need a configuration file to telllockrwhat to do. Its usually calledlockr.inibut can be any name also be anywhere,
as long as it is readable and in the right format.To find usage instructions run:lockr --help
lockr run --helpA general configuration looks as follows:# LockR default configuration file[lockr]# LockR timeout in milliseconds. Higher values mean it will take longer before a# downed node is recognized, lower values mean more Redis traffic.timeout=1000# defaults to 1000# Name of the lock. If empty, generated from the command. Defaults to 'lockr'lockname=test-lockr# Command to execute. This is the process you want to start up. MUST BE SPECIFIED# Examples are: Flask app, celery worker , anything which you don't want to run on more than one node at a timecommand="echo 'test lockr'"# Whether or not to run command in shell. Defaults to 'no'use_shell=no# Specify any custom lock prefix for the lock value stored in key 'lockname'# Defaults to 'LockR'. Accepts environment variables as welllock_prefix=test-prefix[redis]# defaults to localhost. Specify environment variable or pass directly as well. Conflicts with 'cluster_nodes' (only one can be specified).host=${REDIS_HOST}# Specify all the cluster nodes each in new line. Conflicts with 'host' (only one can be specified).# Currently only works with environment variables# The nodes must have cluster mode enabledcluster_nodes=${REDIS_HOST}:${REDIS_PORT}# port is optional and defaults to 6379. Specify environment variable or pass directly as wellport=${REDIS_PORT}# In single Redis server mode only, you can SELECT the database. Defaults to 0. Ignored for cluster_nodesdatabase=1All the default parameters are optional, which take the default value if nothing is specified. It is recommended not to update them,
unless you want to fine tune yourlockrinstance.Then just run:lockr run --dry-runIf your config file is valid, you should see the output:Valid configuration found. Dry run verification successfulOnce, you’ve confirmed the file is valid, run:lockr runDevelopmentLockRis available onGitHubOnce you have the source you can run the tests with the following commandspip install -r requirements.dev.txt
pytest tests/