3

I have more than 100 sites that need to be maintained. So I am looking for way to put up a notice message for this group of sites. For example: We are having maintenance scheduled for tomorrow 10 PM. The message will be persisting for a time being for all the sites.

Here I am assuming that there should be a central node from where we can push a message to all sites at once and delete when required.

So, I am looking for some help if there is already existing set of tools or way I can implement the workflow.

I have tried Drupal Remote Dashboard module, the module seems to offer site monitoring from master node (site), but it doesn't seem to offer the global messaging option.

6 Answers 6

3
+25

The nice thing in the "Drupal Remote Dashboard" module that you can run cron on your sites, so I would suggest that you build a custom messaging module that pull messages from master site (using cron to fire that). - you can use services module to push your messages out

2

Worth looking.

https://www.drupal.org/project/site_notice

Use cases for notices may include:

Scheduled downtime
Holiday office hours
Policy updates
New features

1
  • This module isn't useful in it's current state, because it doesn't allow you to set up notices for multiple sites at one. But there is planned Drush integration, which would allow to automate work using something like Ansible. Commented Sep 12, 2015 at 17:34
2

You can have a separate maintenance.html page in your web root and copy of vhosts file for all of your sites something as

site.conf.live
site.conf.maintenance

Inside site.conf.live webroot will be drupal installation while in site.conf.maintenance webroot will be maintenance.html page.

So at a time any of the two file will be synlinked to original vhost file which will decide whether site is live or in maintenance. You can create a script to update all symlinks from live to maintenance and another one from maintenance to live.

As a admin you will have to login using server ip

Updated Answer

Option 1.

You can use combination of features module + strongarm and a custom module. Custom Module will hold configuration form and logic to show splash message. On one of your site you will update message to show in the configuration page from your custom module, pull it in features, push the feature across all sites, it will require scripts to automate code push/pull, feature revert and turn on/off of custom module.

Option2.

You can try using third party tools like Web-Engage. It has a drupal integration module also. You can try it can provide you one place for setting up notification.

Option3.

You can have a custom table in all your sites. with columns as Message ID, Message, Timestamp, write a small scripts which loops over all your sites connect to mysql one by one and insert a new message row to the message table. To show the message you can create a custom module which pulls the latest entry from your custom message table and show on a popup, again a small script which all turn on/off this module by drush command looping all your sites.

2
  • thanks for the answer @arpitr but my goal here is to put the persisting notice message on the sites, prior to taking site in maintenance. And the message could be something like "Events happening on 2016" :)
    – shrish
    Commented Sep 10, 2015 at 7:12
  • @shrish added few more pointers if it helps you. Check under updated answer.
    – arpitr
    Commented Sep 12, 2015 at 17:44
1

Solution 1:

If the websites are hosted on the same machine you could use redis module and Implement the pub/sub messaging protocol between websites using redis api in your case you could have one website(node) acts as publisher and others acts as subscriber and using nodejs to run queries against DB to put site under maintaince or what ever you want

Solution 2:

Or you could implement the same technique with socket io with nodejs too if it was not in the same machine using any headless browser tools like phantomJs to start socket connect without opening browser session.

My solutions may need extra work outside drupal framework

1

You will not find a simpler solution

TL;DR : Use RSS and PHP!

Caveat : Unfortunately not as elegant as a simple module installation & configuration, This involves creating a feed view, and php code to process the rss in a block.

Step 1

a) On the control site, use nodequeue to easily insert and remove message nodes. In a Feed(rss) type view add Nodequeue as relationship and sort criteria

Step 2

Make a block on each other site with the following php :

<?php
    $rss = new DOMDocument();
    $rss->load('http://mydrupalsite.org/message/feed/');
    $feed = array();
    foreach ($rss->getElementsByTagName('item') as $node) {
        $item = array ( 
            'title' => $node->getElementsByTagName('title')->item(0)->nodeValue,
            'desc' => $node->getElementsByTagName('description')->item(0)->nodeValue,
            );
        array_push($feed, $item);
    }
    $limit = 1;
    for($x=0;$x<$limit;$x++) {
        $title = str_replace(' & ', ' &amp; ', $feed[$x]['title']);
        $description = $feed[$x]['desc'];
        echo '<h2>'.$title.'</h2>';
        echo '<p>'.$description.'</p>';
    }
?>

Adjust the output to your own liking.

The advantage of using Nodequeue, is that you can keep your node(for sytle or generic message), and just remove it from the queue.

(We tried going with contrib modules such as aggregator, feeds, etc, but had issues with cache and specifically cron being used to import items, that would persist once messages were removed from the source feed!)

1

Below is an approach based on site building techniques only, which only uses commonly used modules with a stable release, and leaves a lot of options open for further refinements.

Step 1

Define a content type in your "master" site (= cfr. your "central node"), with these custom fields:

  • notice message: to store the actual message to be shown.
  • date/time from: the start date and time for the message to be shown.
  • date/time to: the end date and time for the message to be shown.

Using content editing features, create a node in this master site for each message to be shown "somewhere in the future". You may want to set permissions for these kinds of nodes to be created by selected roles only.

Step 2

Define the same content type in each "slave" site (= cfr. your "group of sites"). You can probably automate this process (so that you don't have to do this manually "over 100 times" ...), using export/import features, e.g. by using the Features module.

Step 3

Implement a process to periodically "copy" the nodes created in the master site to each of the slave sites. A few possible solutions for this:

Step 4

In each of the slave sites, use the Rules module to create:

  • a Rules component "Display notice messages" with these specs:

    • use the "node id" as a parameter.
    • Condition: current date/time is between date/time from and date/time to.
    • Action: display notice message in the Drupal message area.
  • a rule with these specs:

    • Event: when (selected) content is "going to be viewed". Attention: that's different from "when viewing content"!
    • Action: Loop over each of the existing nodes as created in step 3, and execute the Rules component "Display notice messages" (passing the node id as a parameter).

Step 5

To remove the obsoleted nodes later on (cfr. your "delete when required"), simply build a list of them using the Views module, and combine it with the Views Bulk Operations module so that the resulting list can be processed by the Rules module (to delete those nodes again).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.