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

Script path and 404 while running your Quicksilver operation #182

Open
jigarius opened this issue Aug 10, 2022 · 2 comments
Open

Script path and 404 while running your Quicksilver operation #182

jigarius opened this issue Aug 10, 2022 · 2 comments

Comments

@jigarius
Copy link

jigarius commented Aug 10, 2022

The problem

  • I followed the instructions on this README and created a similar script.
    • I put my script under web/private and it didn't work.
    • I put it under scripts/quicksilver/custom/drupal-deploy.php and mentioned correctly in the pantheon.yml but it still didn't work
  • The script doesn't work and the error message is not clear.
    • I get 404 while running your Quicksilver operation, but I'm not sure how I get a 404 if all I'm trying to do is run a script.
    • Also, since this is a script that is not to be accessed by the public, I wonder why the README suggests putting it inside web/private instead of private/ or scripts/.

/pantheon.yml

api_version: 1
web_docroot: true
php_version: 7.4
database:
  version: 10.4
workflows:
  sync_code:
    after:
      - type: webphp
        description: Run drush-deploy on test and live
        script: scripts/quicksilver/custom/drush-deploy.php

/scripts/quicksilver/custom/drush-deploy.php

<?php

// Do nothing if not on Pantheon test/live environments.
if (!in_array($_ENV['PANTHEON_ENVIRONMENT'], ['test', 'live'])) {
  return;
}

$commands = [
  'drush updatedb --no-cache-clear --yes',
  'drush cache:rebuild',
  'drush config:import --yes',
  'drush cache:rebuild',
  'drush config:import --yes',
  'drush cache:rebuild',
  'drush locale:check',
  'drush locale:update',
  'drush deploy:hook',
  'drush cache:rebuild',
];

foreach ($commands as $command) {
  echo "Running: $command" . PHP_EOL;
  passthru($command);
}

I wonder what's going on? What does 404 while running your Quicksilver operation mean?

@mojibake-umd
Copy link

mojibake-umd commented Aug 16, 2022

let's just say the documentation is confusing at best...
I too have been running in circles this morning trying to cut my teeth on Quicksilver scripts...
The below finally worked for me 3minutes ago.
Using the standard Pantheon upstream for Drupal the following worked for me.
pantheon.yml
# Put overrides to your pantheon.upstream.yml file here.
api_version: 1
#quicksilver scripts
workflows:
deploy:
after:
- type: webphp
description: Drush Example
script: private/scripts/enable_dev_modules.php

I first placed in /files/private/scripts/ (403)
and then in /code/private/scripts/ (302)
it did not work until I placed in
/code/web/private/scripts
which would be in the "web" subdirectory of the site repo.

If you are using the default upstream, then maybe you do not need web_docroot: true (please verify)

@jigarius
Copy link
Author

Findings

  • The terminus workflow:watch SITE says, script can't be found, check your path, but it doesn't make it clear as to where it looked for it.
    • Maybe in the --verbose mode it could help the user with additional information like, script not found at web/private/..., which could make it easier to debug the issue.
  • Turns out that when we write script: private/scripts/..., Pantheon looks for this path inside the web directory, which doesn't seem intuitive.

So, in my case, it works now because I placed the script under web/private/scripts/... and wrote the script: as private/scripts/... without the web/ in the beginning.

Suggestions

  • IMHO, the script: path/to/script.ext should look up the script from the project root and not the web root.
  • Also, such server-side scripts are usually placed above Drupal's document root for security reasons.
    • I'd suggest considering the documentation to suggest placing these scripts under some location like PROJECT/scripts/quicksilver/ so they stay above Drupal's document root.

I'll keep this open for now so that my suggestions are read by the maintainers.

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

2 participants