2

Is there a way with Drush or something else to check if a specified Drupal site is still up and running, means fully normal functioning, after automated maintenance/updating in an external script?

Sometimes an update can fail in a script and then there is a none-functional site left. I want to detect that situation. So have a command and the output is the status of the site? E.g.

drush <command> <site>

yields down/up or something.

The drush status command doesnt seemed to have such functionality.

Edit

When I was searching for the tools suggested in the comments I see that i was unspecific in the beginning, sorry for that. I mean the script is updating Drupal core and modules via Composer and Drush e.g.

~/bin/composer.phar update drupal/core "drupal/core-*" --with-all-dependencies
drush updatedb -l $WEBSITENAME
drush cache:rebuild

So I don't speak about updating whole servers and systems, just automated updating Drush, core and modules.

13
  • 2
    How do you define "up and running"?
    – Jaypan
    Feb 6 at 15:36
  • 1
    @Jaypan That's exactly what I was going to ask. Drush doesn't "know" anything about the web server as far as I know.
    – cilefen
    Feb 6 at 15:39
  • 1
    Health checks should be performed by an external system
    – Clive
    Feb 6 at 15:40
  • 1
    This is a better suited task to server monitoring / healthcheck apps.
    – Kevin
    Feb 6 at 15:40
  • 1
    I use Uptime Robot myself: uptimerobot.com
    – Jaypan
    Feb 6 at 15:44

1 Answer 1

3

The simplest definition of a running site is that it returns a status code 200. From the command line or a script, you could use wget or curl.

If you want to avoid these tools a Drush only solution would be using the built-in guzzle client:

drush ev "echo Drupal::httpClient()->head('www.example.com')->getStatusCode();"

Your Answer

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

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