diff --git a/.do/app.yaml b/.do/app.yaml index 7acd69b8..42ceb162 100644 --- a/.do/app.yaml +++ b/.do/app.yaml @@ -153,3 +153,35 @@ workers: name: background-tasks run_command: php .do/run-background-tasks.php source_dir: / + +jobs: +- environment_slug: php + github: + branch: 9.x + repo: neurocracy/omnipedia + instance_count: 1 + instance_size_slug: professional-xs + kind: PRE_DEPLOY + name: pre-deploy + run_command: .do/jobs/pre-deploy.sh + source_dir: / +- environment_slug: php + github: + branch: 9.x + repo: neurocracy/omnipedia + instance_count: 1 + instance_size_slug: professional-xs + kind: POST_DEPLOY + name: post-successful-deploy + run_command: .do/jobs/post-successful-deploy.sh + source_dir: / +- environment_slug: php + github: + branch: 9.x + repo: neurocracy/omnipedia + instance_count: 1 + instance_size_slug: professional-xs + kind: FAILED_DEPLOY + name: post-failed-deploy + run_command: .do/jobs/post-failed-deploy.sh + source_dir: / diff --git a/.do/deploy-tasks.sh b/.do/deploy-tasks.sh deleted file mode 100755 index c5f335d2..00000000 --- a/.do/deploy-tasks.sh +++ /dev/null @@ -1,4 +0,0 @@ -#!/bin/bash - -# Run any necessary database updates. -drush -y updb diff --git a/.do/deploy.template.yaml b/.do/deploy.template.yaml index 0df2d044..886e85c3 100644 --- a/.do/deploy.template.yaml +++ b/.do/deploy.template.yaml @@ -155,3 +155,35 @@ spec: name: background-tasks run_command: php .do/run-background-tasks.php source_dir: / + + jobs: + - environment_slug: php + github: + branch: 9.x + repo: neurocracy/omnipedia + instance_count: 1 + instance_size_slug: professional-xs + kind: PRE_DEPLOY + name: pre-deploy + run_command: .do/jobs/pre-deploy.sh + source_dir: / + - environment_slug: php + github: + branch: 9.x + repo: neurocracy/omnipedia + instance_count: 1 + instance_size_slug: professional-xs + kind: POST_DEPLOY + name: post-successful-deploy + run_command: .do/jobs/post-successful-deploy.sh + source_dir: / + - environment_slug: php + github: + branch: 9.x + repo: neurocracy/omnipedia + instance_count: 1 + instance_size_slug: professional-xs + kind: FAILED_DEPLOY + name: post-failed-deploy + run_command: .do/jobs/post-failed-deploy.sh + source_dir: / diff --git a/.do/jobs/post-failed-deploy.sh b/.do/jobs/post-failed-deploy.sh new file mode 100755 index 00000000..246957d4 --- /dev/null +++ b/.do/jobs/post-failed-deploy.sh @@ -0,0 +1,9 @@ +#!/bin/bash + +# Disable maintenance mode. +# +# The database is shared between all deploys, even failed ones, so we need to +# turn off maintenance mode so that the live copy of the site (not this failed +# deploy) is publicly accessible again. +drush maint:set 0 +echo "=> Maintenance mode has been turned off" diff --git a/.do/jobs/post-successful-deploy.sh b/.do/jobs/post-successful-deploy.sh new file mode 100755 index 00000000..1b26fbad --- /dev/null +++ b/.do/jobs/post-successful-deploy.sh @@ -0,0 +1,5 @@ +#!/bin/bash + +# Disable maintenance mode. +drush maint:set 0 +echo "=> Maintenance mode has been turned off" diff --git a/.do/jobs/pre-deploy.sh b/.do/jobs/pre-deploy.sh new file mode 100755 index 00000000..a9acad1c --- /dev/null +++ b/.do/jobs/pre-deploy.sh @@ -0,0 +1,8 @@ +#!/bin/bash + +# Enable maintenance mode. +drush maint:set 1 +echo "=> Maintenance mode has been turned on" + +# Run any necessary database updates. +drush -y updb diff --git a/.do/run-background-tasks.php b/.do/run-background-tasks.php index 567d0453..3d9b4b74 100644 --- a/.do/run-background-tasks.php +++ b/.do/run-background-tasks.php @@ -18,14 +18,6 @@ (new WorkerProcess(__DIR__ . '/run-common.sh'))->start(); }); -# Run deploy tasks. Note that this assumes only one background tasks worker. -# -# @todo Rework this to ensure it only runs once on deploy, either as an App -# Platform job or using some form of locking. -$loop->futureTick(function(): void { - (new WorkerProcess(__DIR__ . '/deploy-tasks.sh'))->start(); -}); - // Run cron every 15 minutes. $loop->addPeriodicTimer(900, function(): void { (new WorkerProcess('drush cron'))->start();