Score:2

How can I check with if my site is running?

cx flag

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.

Jaypan avatar
de flag
How do you define "up and running"?
id flag
@Jaypan That's exactly what I was going to ask. Drush doesn't "know" anything about the web server as far as I know.
gzwg avatar
cx flag
@Jaypan i tried to make my question clearer in that respect
cn flag
Health checks should be performed by an external system
Kevin avatar
in flag
This is a better suited task to server monitoring / healthcheck apps.
gzwg avatar
cx flag
@Clive what do you mean by this?
cn flag
Find a service which will ping your site every x seconds and report/notify a non-200 response. Drush is a command line tool, so asking it to detect whether your site, a stateless http application, is up, is a losing battle
gzwg avatar
cx flag
@Kevin thanks for the hint, i think that is the external system Clive suggested?
id flag
At the time I write this comment, the question is "Is there a way with drush or something else to check if a specified drupal site is still up and running...". Yes, there are a great many ways to check if any website is up and running. But that's not a Drupal question.
gzwg avatar
cx flag
ok, thanks for the advice, i check out some of the hints in the comments.
Jaypan avatar
de flag
I use Uptime Robot myself: https://uptimerobot.com/
Kevin avatar
in flag
Pingdom, New Relic, just to name a few... there are dozens if not hundreds.
gzwg avatar
cx flag
@Jaypan i see that i was really unspecific with my question so i tried to refine it with an edit.
Score:3
cn flag

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();"
I sit in a Tesla and translated this thread with Ai:

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.