diff --git a/src/Handler.php b/src/Handler.php index caabdd05c2883030b09ff18080b8bb0353ec9e43..197b2e7e811d535a665bbc2236ad47b00fd4d43f 100644 --- a/src/Handler.php +++ b/src/Handler.php @@ -550,7 +550,7 @@ class Handler extends BaseHandler { $activeTasks = []; foreach ($tasks as $name => $task) { $disabled = !empty($task['disabled']); - $command = $task['command']; + $ping_url = FALSE; if (isset($hj_manager)) { unset($task['disabled'], $task['command']); $task['name'] = $name; @@ -601,11 +601,20 @@ class Handler extends BaseHandler { } } if ($check) { - $command .= ' && curl -fsS --retry 5 -o /dev/null ' . $check['ping_url']; + $ping_url = $check['ping_url']; } } if (!$disabled) { - $activeTasks[] = $task['schedule'] . ' ' . $command; + if (count(explode(' ', $task['schedule'])) === 5) { + // Add leading "*" for seconds. + $task['schedule'] = '* ' . $task['schedule']; + } + $activeTasks[] = [ + 'name' => $task['name'], + 'schedule' => $task['schedule'], + 'command' => $task['command'], + 'ping_url' => $ping_url, + ]; } } if (empty($activeTasks)) { diff --git a/templates/crontabs/template.twig b/templates/crontabs/template.twig index f68fe184af60bb83ad492c64c61158febbea6160..a4dd9eea41f7b5eaa51de5043a81f4e89efd9b8f 100644 --- a/templates/crontabs/template.twig +++ b/templates/crontabs/template.twig @@ -1,3 +1,9 @@ {% for line in loopoptions|default([]) %} -{{ line|raw }} +[job-exec "{{ line.name }}"] +no-overlap = true +schedule = {{ line.schedule }} +container = {{ projectname }}-php-1 +command = {{ line.command }}{% if line.ping_url %} && curl -fsS --retry 5 -o /dev/null {{ line.ping_url }}{% endif %} + + {% endfor %} diff --git a/templates/docker-compose.yml.twig b/templates/docker-compose.yml.twig index 333c26ba638dfc3620b660ffe5fb5459a844a4f8..aaae71ce719a7cd6aadf1e8e44544d3dff9b8f2d 100644 --- a/templates/docker-compose.yml.twig +++ b/templates/docker-compose.yml.twig @@ -90,6 +90,9 @@ services: - {{ projectroot }}/drush:/etc/drush {% if drupal.live|default(0) %} - {{ projectrootfiles }}:/data/default +{% if backup.enable|default(0) %} + - {{ projectrootfiles }}/db:/var/backups/mysql +{% endif %} {% endif %} {% if php.ssh and not drupal.live|default(0) %} - {{ php.ssh_auth_sock }}:/ssh-agent @@ -108,40 +111,13 @@ services: {% if crontabs.enable|default(0) %} cron: - image: 'wodby/drupal-php:{{ php.version }}' + image: mcuadros/ofelia:latest restart: unless-stopped - environment: -{% if mailhog.enable %} - PHP_SENDMAIL_PATH: /usr/sbin/sendmail -t -i -S mailhog:1025 -{% endif %} - DB_HOST: mariadb - DB_USER: drupal - DB_PASSWORD: drupal - DB_NAME: drupal - DB_DRIVER: mysql - COMPOSER_ALLOW_SUPERUSER: 1 -{% if php.ssh and not drupal.live|default(0) %} - SSH_AUTH_SOCK: /ssh-agent -{% endif %} volumes: - /etc/timezone:/etc/timezone:ro - /etc/localtime:/etc/localtime:ro - - {{ projectroot }}:/var/www/html - - {{ projectroot }}/drush:/etc/drush - - {{ projectrootfiles }}:/data/default - - {{ projectroot }}/crontabs:/etc/crontabs -{% if php.ssh and not drupal.live|default(0) %} - - {{ php.ssh_auth_sock }}:/ssh-agent -{% endif %} -{% if backup.enable|default(0) %} - - {{ projectrootfiles }}/db:/var/backups/mysql -{% endif %} - extra_hosts: - - '{{ projectdomain }}:{{ docker0.ip }}' -{% for subdomain in relatedprojectdomains %} - - '{{ subdomain }}:{{ docker0.ip }}' -{% endfor %} - command: sudo -E crond -f -d 0 + - /var/run/docker.sock:/var/run/docker.sock:ro + - {{ projectroot }}/crontabs:/etc/ofelia/config.ini {% endif %} {{ webserver.type }}: