skip to Main Content

I am using centos docker image to build a container and host drupal site. I need to run drush commands after apache starts. But every commands after apache starts doesn’t run. Is there any way to run drush commands after apache starts? My start up script has following lines:

/usr/sbin/httpd -DFOREGROUND
drush updb -y

2

Answers


  1. Apache might be taking some time to start, after you fire that command. And, your drush command might be executing even before apache has successfully started.

    There can be two ways:

    1. Either you put a static sleep before running drush commands.
    2. after apache start command, you can put a loop which checks apache status, if status not running, then sleep. Else break from loop. And after this, you can run your drush commands.
    Login or Signup to reply.
  2. "Where" is this been executed? If it is not in your drupal home directory or below probably drush can’t find your site.
    Try "cd /var/www/html/orwhateverdirthesitehave" before drush.
    On the other hand it doesn’t seem safe to run this data model changes automatically. Only need to run that when a module is updated AND the updated requires a data model change… IMHO it’s to risky to automate like this.
    If it’s not about updb exactly consider using a secondary script with all the drush stuff and starting changing the working dir to the drupal instalation path.

    /usr/sbin/httpd -DFOREGROUND
    /home/myuser/drushcommands.sh
    

    and in drushcommands.sh

    !#/bin/sh
    cd /var/www/html/mydrupal
    drush cim -y
    ...
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search