quicksilver-examples icon indicating copy to clipboard operation
quicksilver-examples copied to clipboard

Example wanted: Post Solr schema after creating new multidev env with Drupal

Open DavidHernandez opened this issue 7 years ago • 5 comments

Related to #62, we tried to implement the "autoposting" solr schema using the create_cloud_development_environment event with no luck.

On our pantheon.yml file we have this:

api_version: 1

workflows:
  create_cloud_development_environment:
    after:
      - type: webphp
        description: Enables Solr backend
        script: private/quicksilver-scripts/configure_solr.php

Then, we have the configure_solr.php file, that contains the next code:

<?php
// Prevent this script to be executed out of pantheon.
if (!defined('PANTHEON_ENVIRONMENT') || (PANTHEON_ENVIRONMENT === 'live')) {
  return;
}

// Bootstrap Drupal using the same technique as is in index.php.
define('DRUPAL_ROOT', $_SERVER['DOCUMENT_ROOT']);
require_once DRUPAL_ROOT . '/includes/bootstrap.inc';
drupal_bootstrap(DRUPAL_BOOTSTRAP_DATABASE);
$default_path = 'sites/all/modules/apachesolr/solr-conf/solr-3.x/schema.xml';
$schema_path = variable_get('pantheon_apachesolr_schema', $default_path);
pantheon_apachesolr_post_schema_exec($schema_path);

But this code is not working and I can not figure out why. Also, I tried to debug it following the steps mentioned in the troubleshooting part of the quicksilver documentation, it says to use terminus workflow:list to get the logs. I just created a new multidev environment and it does not even appear on the list of workflows, so is not possible to get the logs.

DavidHernandez avatar Jan 25 '18 12:01 DavidHernandez

Seems Gizra hits again. I now also have this requirement :)

@DavidHernandez did you find a solution for this?

amitaibu avatar Oct 10 '18 08:10 amitaibu

I see there is no way of hooking into it, but on my Site install script I could run a a similar script to do it

amitaibu avatar Oct 10 '18 08:10 amitaibu

I'm not sure that you can manually bootstrap from a Quicksilver script. Try using exec or passthru with the drush that is in the current PATH, and run drush php-script to run your schema-posting code. In theory, that should work.

greg-1-anderson avatar Oct 10 '18 18:10 greg-1-anderson

Hi @greg-1-anderson 😄

I think there are two cases here. One that is for new multi-dev, where Solr is already assumed to be enabled (David's scenario)

And the other is upon spinning a new site (my scenario). So in my case, I probably wouldn't want a hook, since it's not guaranteed Solr is already enabled.

Try using exec or passthru with the drush

Can you please clarify where to place the exec -- I didn't get this part.

amitaibu avatar Oct 10 '18 18:10 amitaibu

Yes, I was only addressing the create_cloud_development_environment scenario. I think it might be difficult or impossible to enable solr every time a site is spun up from an upstream (e.g. via a deploy_product hook).

My suggestion was to make your quicksilver hook run a script via Drush:

<?php

passthru('drush php-script private/scripts/my_post_schema.php');

Then, in private/scripts/my_post_schema.php:

$default_path = 'sites/all/modules/apachesolr/solr-conf/solr-3.x/schema.xml';
$schema_path = variable_get('pantheon_apachesolr_schema', $default_path);
pantheon_apachesolr_post_schema_exec($schema_path);

Disclaimer: Untested. I suspect, but do not guarentee that the above should work. Some assembly (or debugging) required.

greg-1-anderson avatar Oct 10 '18 19:10 greg-1-anderson