Commit 3a701bfa authored by Stephane Bouvry's avatar Stephane Bouvry
Browse files

Travaux en cours

parent e3a64d54
Loading
Loading
Loading
Loading
Loading
+8 −0
Original line number Diff line number Diff line
@@ -2,3 +2,11 @@ deploy/
vendor/
.idea
.DS_Store
*~
# Données cache/etc
var
!var/.gitkeep

# Configuration local
.env

bin/worker.php

0 → 100644
+66 −0
Original line number Diff line number Diff line
<?php

chdir(dirname(__DIR__));

$consoleCmd = 'php bin/console.php';

// Worker
$gearmanhost = 'application-gearman';
$worker = new GearmanWorker();
$worker->addServer($gearmanhost);

$worker->addFunction('helloworld', 'triggerHelloworld');
$worker->addFunction('doGearmanTask1', 'triggerDoGearmanTask1');
$worker->addFunction('error', 'triggerError');

$execDev = "2";
echo "Worker ready ($gearmanhost / $consoleCmd) \n";

while ($worker->work()) {
    ;
}

function executeCommande( string $cmd ) :void
{
    echo "[worker] exec $cmd\n";
    $out = exec($cmd);
    if( $out === false ){
        echo "[worker] ERROR : " . $cmd . "\n";
    }
}

function triggerError(GearmanJob $job)
{
    global $consoleCmd;
    try {
        $cmd = $consoleCmd . ' apptest:one -m error';
        executeCommande($cmd);
    } catch (Exception $e) {
        echo "[ERR] " . $e->getMessage() . "\n";
    }
}

function triggerDoGearmanTask1(GearmanJob $job)
{
    global $consoleCmd;
    $params = json_decode($job->workload());
    echo "triggerDoGearmanTask1, " . json_encode($params) . "\n";
    try {
        $cmd = $consoleCmd . ' apptest:one -m ' . json_encode($params);
        executeCommande($cmd);
    } catch (Exception $e) {
        echo "[ERR] " . $e->getMessage() . "\n";
    }
}


function triggerHelloworld(GearmanJob $job)
{
    global $consoleCmd;
    try {
        $cmd = $consoleCmd . ' apptest:one -m "Bonjour monde"';
        executeCommande($cmd);
    } catch (Exception $e) {
        echo "[ERR] " . $e->getMessage() . "\n";
    }
}

compose.yml

0 → 100644
+64 −0
Original line number Diff line number Diff line
networks:
  application-network:
    driver: bridge

services:
  application-postgres:
    container_name: application-postgres
    restart: always
    environment:
      POSTGRES_USER: db_user
      POSTGRES_PASSWORD: db_pass
      POSTGRES_DB: db_exemple
    networks:
      - application-network
    env_file:
      - .env
    ports:
      - 6543:5432
    volumes:
      - ./var/postgres_data:/var/lib/postgresql/data
      - ./install/docker-config/postgresql/docker-entrypoint-initdb.d/:/docker-entrypoint-initdb.d
    build:
      context: ./install/docker-config/
      dockerfile: Dockerfile-postgresql

  application-apache:
    container_name: application-apache
    restart: unless-stopped
    volumes:
      - ./:/var/application
    depends_on:
      - application-gearman
    networks:
      - application-network
    env_file:
      - .env
    build:
      context: ./install/docker-config/
      dockerfile: Dockerfile-apache
    ports:
      - 8888:80

  application-gearman:
    container_name: application-gearman
    image: artefactual/gearmand:1.1.21.2-alpine
    networks:
      - application-network
    tty: true
    restart: "unless-stopped"

  application-worker:
    container_name: application-worker
    restart: unless-stopped
    volumes:
      - ./:/var/application
    depends_on:
      - application-gearman
    networks:
      - application-network
    env_file:
      - .env
    build:
      context: ./install/docker-config
      dockerfile: Dockerfile-worker
 No newline at end of file
+1601 −1574

File changed.

Preview size limit exceeded, changes collapsed.

+4 −4
Original line number Diff line number Diff line
@@ -12,12 +12,12 @@ return [
            'orm_default' => [
                'driverClass' => Driver::class,
                'params' => [
                    'host' => 'db',
                    'dbname' => 'demo',
                    'host' => 'application-postgres',
                    'dbname' => 'exemple',
                    'port' => '5432',
                    'charset' => 'utf8',
                    'user' => 'admin',
                    'password' => 'admin',
                    'user' => 'user',
                    'password' => 'pass',
                ],
            ],
        ],
Loading