Drall - a tool to that helps run drush commands on multi-site Drupal installations

Overview

Drall

Drall is a tool to that helps run drush commands on multi-site Drupal installations.

One command to drush them all. — Jigarius

A big thanks and shout-out to Symetris for sponsoring the initial development of Drall.

Installation

Drall is listed on Packagist.org. Thus, it can easily be installed using composer as follows:

composer require jigarius/drall

Commands

To see a list of commands offered by Drall, run drall list. If you feel lost, run drall help or continue reading this documentation.

exec

There are a number of ways to run drush commands on multiple sites.

With @@uri

In this method, the --uri option is sent to drush.

drall exec --uri=@@uri core:status

Or simplify omit the --uri=@@uri and it will be added automatically.

drall exec core:status
Example
$ drall core:status
drush --uri=default core:status
drush --uri=donnie core:status
drush --uri=leo core:status
drush --uri=mikey core:status
drush --uri=ralph core:status

Here, the --uri is populated with names of the subdirectories under sites in which the various sites live.

With @@site

In this method, a site alias is sent to drush.

drall exec @@site.local core:status
Example
$ drall exec @@site.local core:status
drush @tmnt.local core:status
drush @donnie.local core:status
drush @leo.local core:status
drush @mikey.local core:status
drush @ralph.local core:status

Here, @@site is replaced with site names detected from various site alias definitions.

site:directories

Get a list of all available site directory names in the Drupal installation. All sites/* directories containing a settings.php file are treated as individual sites.

Example: Usage

$ drall site:directories
default
donnie.com
leo.com
mikey.com
ralph.com

The output can then be iterated with scripts.

Example: Iterating

for site in $(drall site:directories)
do
  echo "Current site: $site";
done;

site:aliases

Get a list of site aliases.

Example: Usage

$ drall site:aliases
@tmnt.local
@donnie.local
@leo.local
@mikey.local
@ralph.local

The output can then be iterated with scripts.

Example: Iterating

for site in $(drall site:aliases)
do
  echo "Current site: $site";
done;

Site groups

Drall allows you to group your sites so that you can run commands on such groups with ease.

drall exec --drall-group=GROUP core:rebuild

Drall groups with site aliases

In a site alias definition file, you can assign site aliases to one or more groups like this:

# File: tnmt.site.yml
local:
  root: /opt/drupal/web
  uri: http://tmnt.com/
  # ...
  drall:
    groups:
      - cartoon
      - action

This puts the alias @tnmt.local in the cartoon and action groups.

Drall groups with sites.*.php

If your project doesn't use site aliases, you can still group your sites using one or more sites.GROUP.php files like this:

# File: sites.bluish.php
$sites['donnie.drall.local'] = 'donnie';
$sites['leo.drall.local'] = 'leo';

This puts the sites donnie and leo in a group named bluish.

Development

Here's how you can set up a local dev environment.

  • Clone the https://github.com/jigarius/drall repository.
    • Use a branch as per your needs.
  • Run docker compose up -d.
  • Run docker compose start.
  • Run make ssh to launch a shell in the Drupal container.
  • Run make provision.
  • Run drall --version to test the setup.
  • Run make lint to run linter.
  • Run make test to run tests.

You should now be able to make ssh and then run drall. A multi-site Drupal installation should be present at /opt/drupal. Oh! And Drall should be present at /opt/drall.

Hosts

To access the dev sites in your browser, add the following line to your hosts file. It is usually located at /etc/hosts. This is completely optional, so do this only if you need it.

127.0.0.1 tmnt.drall.local donnie.drall.local leo.drall.local mikey.drall.local ralph.drall.local

The sites should then be available at:

Acknowledgements

  • Thanks Symetris for funding the initial development.
  • Thanks Jigar Mehta (Jigarius) (that's me) for spending evenings and weekends to make this tool possible.
Comments
  • Fix and improve parallel execution

    Fix and improve parallel execution

    Giving the command: ./vendor/bin/drall exd cr --drall-workers=4 on a site where there are 4 installations, it should do the command under one command time but it's visibly and measurable that it runs serial still, instead of parallel.

    bug enhancement 
    opened by golddragon007 16
  • Run drush commands in parallel

    Run drush commands in parallel

    Requirements

    • Say, there are 200 sites.
    • The user wants to run 5 instances of drush, thereby running commands on 5 sites at a time.
      • User defines number of parallel processes, e.g. --drall-processes=5.
    • Ensure intelligible output.
      • If we run a command like foo &; bar & the lines of output of foo and bar get mixed up.
      • We need to ensure that the output of each drush command appears together and is readable.

    Solution

    • If --drall-processes, say n, is greater than 1, then continue, otherwise, there's nothing special to do.
    • Create a unique ID for the command, e.g. a UUID.
    • Get a list of all the targeted sites.
    • Create a JSON file in the tmp directory to track command progress.
      • Let's call this the task file.
    • Launch n drall commands (let's call these workers) with a reference to the task file.
      • Let's call these Drall workers.
      • E.g. drall --drall-task=/path/to/task.json ... &;.
    • Each Drall worker picks up a site,
      • Takes a task from the list (if it's not empty).
      • Does the task.
      • Obtains a lock on the list.
      • Updates the list.
      • Prints output.
      • Releases lock on the list.

    Tasks

    • [x] Decide task file specifications.
      • [x] Decide task file name and location.
      • [x] Decide task file structure.
    • [x] Create an internal command exec:task.
      • [x] Takes a task path as an argument.
      • [x] Implement task file locking mechanism, i.e. only one process can write to the task file.
      • [x] Implement task execution mechanism, i.e. execute a task/command from the task file and mark it as done.
    • Update the exec:drush command.
      • Support a --drall-processes=n parameter.
      • If n > 1, then generate a task file and launch Drall workers to execute the tasks.
    • [x] Update tests
    • [x] Update documentation
    enhancement 
    opened by jigarius 3
  • Use amphp/process for parallel execution.

    Use amphp/process for parallel execution.

    Tasks

    • [x] Use amphp/process libraries
      • [x] Limit max-workers to match --drall-workers value.
      • [x] Update tests
    • [x] Remove all code from the old implementation of parallel execution
      • [x] Remove Runner/*
      • [x] Remove Queue/*
    • [x] Update README, if required.
    enhancement 
    opened by jigarius 2
  • Allow running multiple commands in parallel

    Allow running multiple commands in parallel

    Tasks

    • [x] PR: Issue #38
    • [x] PR: Create and use RunnerAwareTrait.
    • [x] PR: Create ExecRunner which should use exec() for capturing output and exit code.
    • [x] PR: Create TestCase::testCreateTempFilePath().
    • [x] PR: Create models: Queue\*.
    • [x] PR: Create exec:queue command.
    • [x] Implement --drall-workers=n in exec:shell and exec:drush commands.
    • [x] Ensure proper test coverage.
    • [x] Update README
    enhancement 
    opened by jigarius 2
  • Add support for --root option

    Add support for --root option

    Requirements

    • Passing the --root option should make Drall do site/alias discovery in the correct directory instead of just using PWD.
    • [x] Works with Drupal document root
    • [x] Works with Composer project root
    enhancement 
    opened by jigarius 1
  • Make `drush site:install` optional

    Make `drush site:install` optional

    Requirements

    • Currently, the dev workflow assumes that Drupal is always installed, i.e. drush site:install.
    • In reality, we don't need the Drupal database to develop or test drall unless we really want to test commands that interact with Drupal's database.
    • Thus, a good solution will be to make the database setup optional.
    • This will speed up build times for the Docker setup and in turn, speed up GitHub actions.

    Tasks

    • [x] Make drush site:install optional.
    • [ ] Do not require the database service in CI builds.
    enhancement 
    opened by jigarius 1
  • Run drush commands with --uri or with @alias

    Run drush commands with --uri or with @alias

    Requirements

    All sites in a multi-site don't always have site aliases. Many projects rely on drush's --uri option to run the command on the correct site. Thus, we need to allow users to choose whether they want to use the URI or Drush aliases.

    Todo

    • [x] If the user runs a command with --uri=@@uri, we replace the @@uri with individual site URIs before sending the command to Drush.
    • [x] If the user runs a command with @@site, we replace the @@site with a site alias's name part, i.e. excluding the env part.
    • [x] If the user runs a command without any of the above, we use --uri=@@uri by default.
    enhancement 
    opened by jigarius 1
  • Detect and list sites in a multi-site Drupal installation

    Detect and list sites in a multi-site Drupal installation

    Tasks

    • [x] Add commands to show a list of sites present in the multi-site installation
      • [x] Detect sites using sites/*/settings.php
      • [x] Detect sites using drush alias definitions
      • [x] Preferably, the list of sites should be iterable in shell scripts
    • [x] Use a SiteDetector service to make the code re-usable.

    Notes

    • Only support D8+.
    • Use PHP 8 or higher.
    enhancement 
    opened by jigarius 1
  • Fix tests failing due to change in Drush output.

    Fix tests failing due to change in Drush output.

    There used to be an extra space in front of certain Drush output but now that space is gone. This PR updates the expected output to match the new Drush output which fixes the tests.

    opened by jigarius 0
  • Create models for dealing with Drall queues

    Create models for dealing with Drall queues

    What's done

    • Set up locking mechanism using lock files.
    • Create models to represent Queue data and Queue items.
    • Create model for reading and writing to Queue files.
    enhancement 
    opened by jigarius 0
  • Drall verbosity must not interfere with Drush verbosity

    Drall verbosity must not interfere with Drush verbosity

    Motivation

    • When running a drall command with -vvv, the -vvv gets passed to Drush.
    • Drush output can get very verbose with -vvv and it makes it hard to read the Drall log messages.

    Proposed solution

    • Use something like --drall-verbose and --drall-debug to control Drall's verbosity.
    • These options should not be forwarded to Drush commands.
    enhancement Priority: High 
    opened by jigarius 0
  • Drall stuck when running in Bitbucket pipelines

    Drall stuck when running in Bitbucket pipelines

    Not only Bitbucket, it seems Drall gets stuck without any message when it is executed on aliases that refer to remote environments, e.g.

    drall exd @@site.dev core:status
    

    Maybe there's some kind of dialog that's present in there that we can't see? This seems like a dealbreaker.

    bug Priority: High 
    opened by jigarius 0
  • Support for different progress report formats

    Support for different progress report formats

    Requirements

    • Allow users to view the report in different formats.
    • Some basic formats I to start with are shown below.

    Tasks

    • [ ] Use jigarius/phprogress.
    • [ ] Implement the default format.
      • This is what we already have at the moment, just move the code into a formatter.
    • [ ] Implement the dots format.
    • [ ] Implement the bar format.

    Formats

    Names for these formats have not been decided. Feel free to make suggestions.

    Default

    Running on donnie.com
    Cache rebuild successful.
    
    Running on leo.com
    Cache rebuild successful.
    
    Running on ralph.com
    Cache rebuild successful.
    
    Running on mikey.com
    Command failed.
    Error: Could not connect to database.
    
    Running tmnt.com
    Cache rebuild successful.
    

    Dots

    ...F.
    

    Bar

    60% [====================>----------] [3/5]
    
    enhancement 
    opened by jigarius 1
  • Ensure windows compatibility

    Ensure windows compatibility

    Requirements

    • Drall should work on Windows
      • This will mainly involve using the Windows directory separator \.

    If I get 25 👍🏽 on this issue, I'll start working on it.

    enhancement 
    opened by jigarius 0
  • Use by default aliased command to have correct domains

    Use by default aliased command to have correct domains

    When I simple give the command $ ./vendor/bin/drall exd uli I receive URLs which does not contain the domains:

    Running: drush --uri=eaad uli
    http://eaad/en/user/reset/1/1658916912/XtxmYUYDfYWCNDiF2Jf43DCXuQmpeNo6JbRW1NFIFhQ/login
    Running: drush --uri=escaide uli
    http://escaide/en/user/reset/1/1658916913/nFrSxO18O9BEHqC5E9cYO13pnJpp_2_28_qo5Ai0Rc4/login
    Running: drush --uri=portal uli
    http://portal/en/user/reset/1/1658916913/ugMuDeCVgV0Q5LgUJWTl7fPJ3N7lnDPebipyeVGtoeQ/login
    Running: drush --uri=vaccine uli
    http://vaccine/en/user/reset/1/1658916913/zzinbUGo-UrOm4izTtFtSByJqQQofUl6AHGIzIxgaMY/login
    

    To have it correctly I need to run ./vendor/bin/drall exd @@@uri uli

    Running: drush @eaad uli
    http://ecdc-eaad.lh:8080/en/user/reset/1/1658916788/TpF3oxM2c5b3xuyisYbgfdzJqkBSRvNMgP27JjX4KlA/login
    Running: drush @escaide uli
    http://ecdc-escaide.lh:8080/en/user/reset/1/1658916789/xrZNk927t2Yalo1n3fpPrdRcMY3ZfEN9j_ylpAgjq9o/login
    Running: drush @portal uli
    http://ecdc-portal.lh:8080/en/user/reset/1/1658916789/gIvVSelKq1VyWkXExzQ7kjWFZ_5ZCrYcXI8FKeal6Gk/login
    Running: drush @vaccine uli
    http://ecdc-vaccine.lh:8080/en/user/reset/1/1658916789/NXtzQYeDinF04dF4nU5DyZR3zWMrKp-f4ZjHF4bAKDI/login
    

    I would expect to have the correct url with the simple exd uli command too.

    NOTE: here for us the @@@uri does work as the directory and the drush alias name is actually the same, otherwise it won't work.

    opened by golddragon007 0
Releases(v2.1.0-rc1)
  • v2.1.0-rc1(Sep 21, 2022)

    Here's what's new:

    • Finalizes concurrent execution of commands on multiple sites.
    • Depends on Amphp libraries for concurrent execution of commands.
    • Code and test cleanup.

    As always, if you find any issues or have any suggestions, feel free to share them.

    Source code(tar.gz)
    Source code(zip)
  • v1.1.0(Apr 2, 2022)

  • v2.0.0-rc1(Apr 2, 2022)

  • v1.1.0-rc1(Mar 20, 2022)

    What's Changed

    • Run vendor/bin/drush when available by @jigarius in https://github.com/jigarius/drall/pull/28
    • Mark exec and ex commands as deprecated by @jigarius in https://github.com/jigarius/drall/pull/30
      • Use drall exec:drush instead.
      • In v2.x, drall exec:shell will be introduced.
    • Add support for a --root option by @jigarius in https://github.com/jigarius/drall/pull/32

    As always, feedback and suggestions are always welcome.

    Source code(tar.gz)
    Source code(zip)
  • v1.0.0-beta1(Mar 4, 2022)

    After a week of heavy duty, all the features planned for v1.0.0 are in place. Here's what's done since the last release:

    • Code cleanup.
    • Add unit and integration tests.
    • Set up automated testing with GitHub Actions.
    • Improve README.

    Feel free to give Drall a chance. Your feedback is always welcome.

    Source code(tar.gz)
    Source code(zip)
  • v0.5.0(Mar 1, 2022)

    What's done

    • Most features work correctly, however there are no tests yet.
    • Intended for people who wish to test the project and provide feedback, suggestions, and bug reports.
    Source code(tar.gz)
    Source code(zip)
Owner
Jigar Mehta
I'm a software engineer based in Montréal, specialized in web development, working with tech like PHP, Ruby, Python, JS and SQL.
Jigar Mehta
The swiss army knife for Magento developers, sysadmins and devops. The tool provides a huge set of well tested command line commands which save hours of work time. All commands are extendable by a module API.

netz98 magerun CLI tools for Magento 2 The n98 magerun cli tools provides some handy tools to work with Magento from command line. Build Status Latest

netz98 758 Dec 28, 2022
Allows installing Drupal extensions event if not compatible with installed drupal/core package

mglaman/composer-drupal-lenient Lenient with it, Drupal 10 with it. Why? The Drupal community introduced a lenient Composer facade that modified the d

Matt Glaman 14 Dec 18, 2022
Perform static analysis of Drupal PHP code with phpstan-drupal.

Perform static analysis of Drupal PHP code with PHPStan and PHPStan-Drupal on Drupal using PHP 8. For example: docker run --rm \ -v $(pwd)/example01

Dcycle 0 Dec 10, 2021
Rah backup - Takes backups from Textpattern CMS installations

rah_backup Packagist | Twitter | Donate Rah_backup keeps your important site safe from disastrous events. Rah_backup is an admin-side backup utility p

Jukka Svahn 5 Apr 24, 2022
A htaccess boilerplate for all Magento Community installations. Features focus on speed, SEO and security.

magento-htaccess A htaccess boilerplate for all Magento Community installations. Features focus on speed, SEO and security. The file should be placed

Creare 114 Sep 18, 2022
Module for integrating Fastly CDN with Magento 2 installations

FASTLY CDN FOR MAGENTO2 DOCUMENTATION Thank you for using the "Fastly CDN module for Magento2" (Fastly_Cdn). This package contains everything you need

Fastly 113 Dec 26, 2022
Enables developers to modify Magento installations (configuration, data) based on the given environment using n98-magerun.

Enables developers to modify Magento installations (configuration, data) based on the given environment using n98-magerun.

LimeSoda Interactive Marketing GmbH 73 Apr 1, 2022
Drupal / Eleventy Docs Site for the Design System

Drupal / Eleventy Docs Site for the Design System

University of Michigan Library 2 Oct 31, 2022
Run the following commands in your terminal to setup the project

Run the following commands in your terminal to setup the project You must have the LAMP installed on your system git clone https://github.com/Bashar-A

null 1 Nov 6, 2021
A multi-purpose web-shell that simplifies running shell commands on webserver

This webshell can be used for multi-purposed especially most if you want to manage your web server but you are in an emergency , so why not use a webshell:)

urchinsec 5 Oct 13, 2022
MajorDoMo is an open-source DIY smarthome automation platform aimed to be used in multi-protocol and multi-services environment.

MajorDoMo (Major Domestic Module) is an open-source DIY smarthome automation platform aimed to be used in multi-protocol and multi-services environment. It is based on web-technologies stack and ready to be delivered to any modern device. It is very flexible in configuration with OOP paradigm used to set up automation rules and scripts. This platform can be installed on almost any personal computer running Windows or Linux OS.

Sergei Jeihala 369 Dec 30, 2022
Talkino allows you to integrate multi social messengers and contact into your website and enable your users to contact you using multi social messengers' accounts.

Talkino Welcome to our GitHub Repository Talkino is a click to chat plugin to show your agents’ multiple social messengers, phone and emails on the ch

Traxconn 2 Sep 21, 2022
This is a PocketMine plugin that helps staffs track players using commands.

Track This is a PocketMine plugin that helps staffs track players using commands. Features Allows selected staffs to watch players use commands to fac

Nguyễn Thành Nhân 6 Jun 23, 2022
Site Web pour un site de conciergerie d'entreprise

DATE DE CREATION : 30 novembre 2021 • Développement d'un site Web pour une entreprise de conciergerie pour entreprise, une interface pour les dirigea

Tiffany Dufetel 1 Jan 10, 2022
Dispatcher is a Laravel artisan command scheduling tool used to schedule artisan commands within your project so you don't need to touch your crontab when deploying.

Dispatcher Dispatcher allows you to schedule your artisan commands within your Laravel project, eliminating the need to touch the crontab when deployi

Indatus 1.1k Dec 21, 2022
Multi-language field export/import tool for ProcessWire

Language field export/import for ProcessWire Typically the way you translate page field values in ProcessWire is to edit a page, view the text in one

Ryan Cramer 3 Aug 19, 2022
PHPCheckstyle is an open-source tool that helps PHP programmers adhere to certain coding conventions.

PHPCheckstyle Overview PHPCheckstyle is an open-source tool that helps PHP programmers adhere to certain coding conventions. The tools checks the inpu

PHPCheckstyle 157 Dec 5, 2022
Ideation Tool helps with the collection, enrichment, rating, and prioritization of ideas.

About Ideation Tool Ideation Tool helps with the collection, enrichment, rating, and prioritization of ideas. We believe having access to simple to us

Innovategy Oy 3 Jun 15, 2022
Workshop environment for Decoupled Drupal

Decoupled Drupal Workshop ?? Welcome to the Bluehorn Digital Decoupled Drupal workshop repository! This repository contains a decoupled ready Drupal b

Bluehorn Digital 6 Feb 2, 2022