espocrm / espocrm-docker

Official Docker Image for EspoCRM
https://hub.docker.com/r/espocrm/espocrm
GNU Affero General Public License v3.0
56 stars 34 forks source link

Cronjob not working #4

Closed ericfischerbav closed 3 years ago

ericfischerbav commented 3 years ago

I've set up Espo pretty almost exactly like you in your example docker-compose. Unfortunatly, I can't get the cronjob to work. Here's the part of my docker compose

  # CRM
  crm-db:
    image: mariadb
    command: --transaction-isolation=READ-COMMITTED --binlog-format=ROW
    restart: always
    volumes:
      - ./data/crm/db:/var/lib/mysql
    env_file:
      - crm.env
    networks:
      - crm

  crm:
    build: ./crm
    restart: always
    volumes:
      - ./data/crm/system:/var/www/html
    depends_on:
      - crm-db
    networks:
      - crm

  crm-cron:
    build: ./crm
    restart: always
    volumes:
      - ./data/crm/system:/var/www/html
    depends_on:
      - crm
    networks:
      - crm
    entrypoint: docker-cron.sh

I'm using the Dockerfile and docker-entrypoint.sh, docker-cron.sh from the apache folder. As there are different settings for the local and production environment, there are more configs publishing the port or hiding behind a reverse proxy.

I'm trying to fetch mails. When I run docker exec -it webapps_crm_1 /bin/bash and then php cron.php in the /var/www/html directory, emails are fetched as it should. However, the cron service doesn't do this job.

Is there anything I'm missing?

tmachyshyn commented 3 years ago

Did you try to use the image from dockerhub, https://hub.docker.com/r/espocrm/espocrm?

ericfischerbav commented 3 years ago

Does not work, either. I made some more tests with this setup:

When running php -f cron.php in docker exec -it webapps_crm_1 /bin/bash, the cron job does it's job as expected. When running it in docker exec -it webapps_crm-cron_1 /bin/bash, The job does nothing. So there is something missing in the connection of both containers.

However, there's a strange phenomena... I'm sending test mails to verify the functionality. Parallel to checking if Espo is fetching mails, I checked, how the inbox in my webmail behaves. Sometimes, a fresh mail which I didn't open in webmail has been marked as read. So maybe the cron job itself is working, but it does not store the mail.

Are mails stored in the filesystem (volume)? Then I may have some acces rights problems.

ericfischerbav commented 3 years ago

How could I verify that the cron job is working? cat /dev/stdout does not finish.

tmachyshyn commented 3 years ago

Just tested with the following docker-compose.yml:

version: '3'

services:

  # CRM
  crm-db:
    image: mariadb
    command: --transaction-isolation=READ-COMMITTED --binlog-format=ROW
    restart: always
    volumes:
      - ./data/crm/db:/var/lib/mysql
    environment:
      MYSQL_ROOT_PASSWORD: example

  crm:
    image: espocrm/espocrm
    restart: always
    volumes:
      - ./data/crm/system:/var/www/html
    depends_on:
      - crm-db
    ports:
      - 8080:80

  crm-cron:
    image: espocrm/espocrm
    restart: always
    volumes:
      - ./data/crm/system:/var/www/html
    depends_on:
      - crm
    entrypoint: docker-cron.sh

EspoCRM and cron are working fine. Could you check your EspoCRM logs, ./data/crm/system/data/logs.

Emails are not stored in the filesystem (volume), only attachments. To verify cron job, you can go to Administrator panel > Scheduled Jobs and select some Job (e.g, Send Email Notifications), and check execution log.

ericfischerbav commented 3 years ago

Thanks a lot for your help! Don't know what went wrong, now I see logs from the cron job. Maybe that just a problem with the Email tool... I don't think anymore this is Docker related.

ericfischerbav commented 3 years ago

Just to clarify: I finally can see logs like:

[2021-03-24 16:27:01] ERROR: CronManager: Failed job running, job [605b67a0a234ada42]. Error Details: Job CheckInboundEmails 6059c0ea57e8220a7: [0] cannot read - connection closed? at /var/www/html/application/Espo/Modules/Crm/Jobs/CheckInboundEmails.php:74 [] []

So I assume this problem is more connection related than cron.