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

UHF-10354: Update documentation #272

Merged
merged 1 commit into from
Oct 18, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 16 additions & 5 deletions documentation/openshift.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,13 @@ See [City-of-Helsinki/drupal-docker-images](https://github.com/City-of-Helsinki/

## Cron

Crons are run inside a separate cron container and use [docker/openshift/crons/base.sh](/docker/openshift/crons/base.sh) as an entrypoint.
Crons are run inside a separate cron container and use [docker/openshift/cron-entrypoint.sh](/docker/openshift/cron-entrypoint.sh) as an entrypoint.

The cron container is run using the same image as the Drupal container and should contain everything your normal container does.

The entrypoint is run only once and the container will die as soon as the "main" loop is finished, meaning that all scripts must be run inside an infinite loop. You can use `sleep XX` to define how often a certain task should be run.
Any scripts placed in repository's `docker/openshift/crons` folder will be copied automatically to `/crons` folder inside the cron container. The entrypoint executes all scripts in `/crons` directory and will die if any of the scripts fail, so that if any of the scripts fail, the whole container exists with a failure. OpenShift automatically restarts failed cron container.

Any scripts placed in repository's `docker/openshift/crons` folder will be copied automatically
to `/crons` folder inside the cron container, but won't be run automatically.
The scripts are not restarted if they exit gracefully, meaning they must be run inside an infinite loop. You can use `sleep XX` to define how often a certain task should be run.

### Running a custom cron

Expand All @@ -39,4 +38,16 @@ do
done
```

then add `exec "/crons/your-custom-cron-script.sh" &` to `docker/openshift/crons/base.sh` to run it.
The scripts should check any preconditions and exit gracefully if they should not be run in some environments. For example, you can use `is_drupal_module_enabled` function from [`docker/openshift/init.sh`](/docker/openshift/init.sh) and exit if required modules are not enabled.

```bash
#!/bin/bash

source /init.sh

if ! is_drupal_module_enabled "helfi_react_search"; then
exit 0
fi

...
```