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

MJML compiler in TCP mode failing in CI on bitbucket #119

Closed
bramski opened this issue Dec 8, 2020 · 10 comments
Closed

MJML compiler in TCP mode failing in CI on bitbucket #119

bramski opened this issue Dec 8, 2020 · 10 comments

Comments

@bramski
Copy link

bramski commented Dec 8, 2020

I'm having some issues getting our CI builds to pass using MJML-django in TCP mode as the renderer. It was working and then quite consistently when we started rendering more emails they started failing:

RuntimeError: MJML compile error (via MJML TCP server): no working server
Number of servers: 1
Timeouts: 0

I'm a bit baffled by the error. It appears that there are working servers but the compilation step is failing immediately.

Bitbucket YAML looks as follows for docker config:

image: python:3.6-jessie

definitions:
  services:
    mysql:
      image: mysql:5.7
      environment:
        MYSQL_DATABASE: pipelines
        MYSQL_ROOT_PASSWORD: *********
    redis:
      image: redis
    mjml:
      image: liminspace/mjml-tcpserver:0.10.2
      environment:
        HOST: "0.0.0.0"
        PORT: "28102"
      expose:
          - "28102"
      ports:
          - "28102:28102"
@liminspace
Copy link
Owner

@bramski could you show your MJML_* django settings?

@bramski
Copy link
Author

bramski commented Dec 8, 2020

MJML_BACKEND_MODE = env('MJML_BACKEND_MODE', default='cmd')
MJML_TCP_SERVERS = [
    ('127.0.0.1', 28102),
]

In the case of our CI environment MJML_BACKEND_MODE becomes tcpserver.

@liminspace
Copy link
Owner

try to use mjml instead of 127.0.0.1 in your django settings

@bramski
Copy link
Author

bramski commented Dec 8, 2020

Hmmm, all the other configured servers for CI use localhost as the hostname. I wasn't aware of the bitbucket docker container setting up local domain names but I'll give it a shot.
i.e. REDIS_CACHE_URL="redis://localhost:6379/zo-enterprise-test" is how I have redis configured for CI on bitbucket pipelines.

@liminspace
Copy link
Owner

and also try to use the default port settings of mjml-tcpserver:

  mjml:
    image: liminspace/mjml-tcpserver:0.10.2

and

MJML_TCP_SERVERS = [
    ('mjml', 28101),
]

note that when you run CI in your configuration case it can use global ports to run services and if you run them more than one or one of them wasn't stopped correctly, you can have an issue with conflicts. just add docker-compose logs in your CI script to see output and to be sure that all services were started before you run your target scripts.

@bramski
Copy link
Author

bramski commented Dec 8, 2020

Yeah this is coming up for me in the wild as well on our dev & staging systems.

@bramski
Copy link
Author

bramski commented Jan 1, 2021 via email

@liminspace
Copy link
Owner

provide all info to reproduce the issue locally and after that I'll try to fix that. currently I don't see any problem neither python library nor docker image. they are working on various projects quite stable and well (including gitlab-ci to run functional and unit tests)

@bramski
Copy link
Author

bramski commented Jan 1, 2021 via email

@liminspace liminspace reopened this Jan 3, 2021
@bramski
Copy link
Author

bramski commented Feb 24, 2021

Had a chance to investigate this further. There seem to be some bugs in bitbucket's docker work. I changed to port 28101 and then updated the definition for the MJML docker container to be much more plain:

    mjml:
      image: liminspace/mjml-tcpserver:0.10.2

That managed to make the ports work correctly. Not sure why "expose" and "ports" were causing this to fail so randomly.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants