Skip to main content
Drupal is a registered trademark of Dries Buytaert
Release: Views Bootstrap 5.5.4 — Minor update available for module views_bootstrap (5.5.4). Release: Rightup theme 1.0.3 — Minor update available for theme vartheme_bs5_rightup (1.0.3). Release: CommentOn 1.0.6 — Minor update available for module commenton (1.0.6). Release: ChatGPT Ads 1.0.3 — Minor update available for module chatgpt_ads (1.0.3). Release: Opensolr Search 5.1.3 — Minor update available for module opensolr_search (5.1.3). Release: ServiceM8 Webform Integration 1.2.1 — Minor update available for module servicem8_webform (1.2.1). Release: PostfixAdmin 1.0.0 — Initial release available for module postfix_admin (1.0.0)! Release: ip_analyser 1.0.3 — Minor update available for module ip_analyser (1.0.3). Module Revived: Swagger-PHP OpenAPI 3 documentation generator 1.0.0 — Module swagger_php updated after 10 months of inactivity (1.0.0). Security Coverage: Microsoft Azure AI — Module ai_provider_azure now has official Drupal security advisory coverage.

Drush Lock

No security coverage
View on drupal.org

Drush commands for handling locks. Allows protecting scripts from harmful
concurrent execution.

Introduction

Drush is a popular tool for controlling Drupal installations from the command
line and is also often included in (shell) scripts interacting with a Drupal
installation. Sometimes, you might get in a situation where the
same script could run multiple times, at roughly the same time, where that is
undesirable. The use case that led to the creation of this module is the
starting of multiple replicas of a Drupal container on Kubernetes, where the
container will automatically apply updates and import configuration on startup.

The commands in this module allow the script to wait for a named ‘lock’, much like the Locking API in Drupal does (note that the locks do not correspond to actual Drupal locks, because Drupal locks should be acquired and released from a single PHP process).

Requirements

This module relies on Drush and Drupal core. If you did not have those already,
you probably don’t need this module.

Installation

Configuration

This module does not require any configuration.

Commands

For more information about these commands, use drush help.

lock:wait

Wait for and acquire a named lock, e.g. drush lock:wait my_lock --delay=60;
wait for the lock named my_lock, for a maximum of 60 seconds.

lock:release

Release the named lock, e.g. drush lock:release my_lock.

Example

Let’s say you have a Drupal installation running on Kubernetes. You arranged
things in such a way that the Drupal image will automatically detect that it
needs to apply updates and import configuration when starting. However, if you
run multiple replicas of your image, you may run into trouble. In general, your
various replicas may all try to apply updates, import configuration, etc. Even
if those individual steps may be protected against concurrent access, the
sequence of the various steps is important too; in general, database updates
should be applied before config import, for example. Enter drush_lock.

With drush_lock, you can add drush lock:wait my_deployment_lock --delay 1800
before your update script, and drush lock:release my_deployment_lock after.
This will ensure only one replica at a time will enter the critical section. The
1800 stands for half an hour, which should be more than enough for most Drupal
update processes to complete.

Maintainers

Current maintainers:

Sponsors

This module was developed with funding from Nuffic, the Dutch organisation for internationalisation in education.

Depends on

Dependencies of the latest stable release

No dependencies recorded for this project.

Required by

Tracked projects that depend on this one

No tracked projects depend on this one yet.

Activity

Tracked releases
3
Tracked since
Oct 2023
Latest release
2 years ago
Releases (12 mo)
0
Maintenance
Dormant

Release Timeline

Releases

Version Type Core Release date
2.0.0-beta2 Pre-release Apr 8, 2024
2.x-dev Dev Apr 8, 2024
2.0.0-beta1 Pre-release Oct 24, 2023