Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
DavidHernandez opened this issue Jan 25, 2018 · 5 comments

Comments

@DavidHernandez
Copy link

DavidHernandez commented Jan 25, 2018

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.

@amitaibu
Copy link

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

@DavidHernandez did you find a solution for this?

@amitaibu
Copy link

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

@greg-1-anderson
Copy link
Member

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.

@amitaibu
Copy link

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.

@greg-1-anderson
Copy link
Member

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants