swooletw / laravel-swoole

High performance HTTP server based on Swoole. Speed up your Laravel or Lumen applications.
MIT License
4.05k stars 390 forks source link

how to configure swooletw/laravel-swoole in laradock supervisor #449

Closed wen-gg closed 3 years ago

wen-gg commented 3 years ago

how to configure swooletw/laravel-swoole in laradock supervisor, or are there other methods, thank you!

Arkanius commented 3 years ago

Hi there.

I don't know if I understood your needs, but, here's an example of docker-compose.yml that I use to run in my projects (locally)

yml

version: '2'

services:
  app:
    command: "true"
    image: alpine:3.4
    volumes:
      - ./:/var/www/app
    links:
      - mysql
    networks:
      - app-network

  php:
    image: vtrgomes/composer-alpine:7.4-swoole
    ports:
      - 80:80
    volumes:
      - ./composer-cache:/composer/cache
    volumes_from:
      - app
    networks:
      - app-network
    links:
      - mysql
      - redis

  redis:
    image: vtrgomes/redis-alpine:latest
    volumes:
      - ./redis-data:/data
    ports:
      - 6379:6379
    networks:
      - app-network

  mysql:
    image: vtrgomes/mysql-57:latest
    volumes:
      - ./db-data:/var/lib/mysql
    environment:
      MYSQL_DATABASE: core
      MYSQL_USER: homestead
      MYSQL_PASSWORD: secret
      MYSQL_ROOT_PASSWORD: root
    expose:
      - 3306
    ports:
      - 3306:3306
    networks:
      - app-network

volumes:
  composer-cache:
    driver: local

networks:
  app-network:
    driver: bridge

All images are from this repo: https://github.com/Arkanius/docker-images

wen-gg commented 3 years ago

@Arkanius Thank you, I didn't make it clear, but that's not the answer I wanted

Arkanius commented 3 years ago

I see, so, what's exaclty your need? I don't know a lot about laradock but when you say supervisor I think you say that your swoole proccess is dying inside of your container, isn't it?

wen-gg commented 3 years ago

@Arkanius This is my configuration, but it doesn't work image

Arkanius commented 3 years ago

For some reason I had this same problem with supervisor (not using with laradock). My solution was to create a loop with swoole start command, This way, every time that swoole dias it will run again.

Another solution you can try to run pm2.

Try something like at your supervisor:

[program:swoole]
command = sh -c "while true; do php artisan swoole:http start; done"
user = laradock
autostart = true
...
wen-gg commented 3 years ago

@Arkanius with your configuration, problems will still occur. my situation is similar to #423 .only enter the workspace to execute commands, configure supervisor all the time 502

Arkanius commented 3 years ago

Have you tried the solution mentioned at #423 ?