Juan Pablo B
Juan Pablo B

Reputation: 525

Call same queue between two laravel applications

I have two laravel projects. Each project is in its own docker container:

First Project:

potatoes:
    build:
      context: ./potatoes
      dockerfile: Dockerfile
      args:
        environment: local
    ports:
      - '5000:80'
    depends_on:
      - redis
      - potatoesdb
      - elasticsearch
    volumes:
      - ./potatoes:/var/www/html/app

Second Project:

  beanstalk:
    build:
      context: ./beanstalk
      dockerfile: Dockerfile
      args:
        environment: local
    ports:
      - '5004:80'
    depends_on:
      - redis
      - beanstalkdb
    volumes:
      - ./beanstalk:/var/www/html/app
    links:
      - potatoes

Each one has its docker configuration with supervisor:

[supervisord]
nodaemon = true
logfile = /tmp/supervisord.log
logfile_maxbytes = 0

[program:php-fpm]
command=/usr/local/sbin/php-fpm --nodaemonize --fpm-config /usr/local/etc/php-fpm.conf
numprocs=1
autostart=true
autorestart=false

[program:nginx]
command =/usr/sbin/nginx -g "daemon off;"
stdout_logfile = /dev/stdout
stdout_logfile_maxbytes = 0
stderr_logfile = /dev/stderr
stderr_logfile_maxbytes = 0

[program:laravel-worker]
process_name=%(program_name)s_%(process_num)02d
command=php artisan queue:work redis --sleep=3 --tries=3
autostart=true
autorestart=true
numprocs=3
redirect_stderr=true
stdout_logfile=/tmp/worker.log

I need to do the following but I don't know if it's possible to do it:

In my first Project I created a job: TestJobQueue. When this job finishes, a job in another project has to be run also named TestJobQueue.

I don't know how to call the same queue for the first and the second project jobs. I don't know if it's a problem with Docker, with the worker or it's just not possible to do.

Any ideas?

Upvotes: 0

Views: 301

Answers (1)

sebasaenz
sebasaenz

Reputation: 1966

It's not possible to do it in the way you presented it because each project is running in a different Docker container so their queues can't be the same.

This is because when you do CMD ["/usr/bin/supervisord"] in your Dockerfile, each project has its own supervisord each of them depending on their own Docker container.

I think you could solve this with docker-compose, it's the best way to work with different Docker containers. Or even create a supervisord container through docker-compose, but I'm not really familiar with that.

Upvotes: 1

Related Questions