|
| 1 | +# Magento 2 Worker Daemon |
| 2 | + |
| 3 | +Daemon for running Magento 2 queue consumers, designed to be run as a systemd/supervisor service. |
| 4 | + |
| 5 | +## Features |
| 6 | + |
| 7 | +- Detects and runs all Magento 2 queue consumers |
| 8 | +- Restarts consumers if they fail/stop |
| 9 | +- Supports running consumers in a different working directory |
| 10 | +- Validates Magento 2 installation before starting consumers |
| 11 | + |
| 12 | +## Installation |
| 13 | + |
| 14 | +```bash |
| 15 | +git clone https://github.com/tdgroot/magento2-worker-daemon.git |
| 16 | +cargo run -- --working-directory /path/to/magento2 |
| 17 | +``` |
| 18 | + |
| 19 | +## Usage |
| 20 | + |
| 21 | +```console |
| 22 | +$ magento2-worker-daemon |
| 23 | +2023-04-28T13:36:12.788Z INFO [magento2_worker_daemon] Found 19 consumers |
| 24 | +2023-04-28T13:36:12.793Z INFO [magento2_worker_daemon] Started 19 t |
| 25 | +``` |
| 26 | + |
| 27 | +### Command line options |
| 28 | + |
| 29 | +```console |
| 30 | +$ magento2-worker-daemon --help |
| 31 | +Usage: magento2-worker-daemon [OPTIONS] |
| 32 | + |
| 33 | +Options: |
| 34 | + -v, --verbose |
| 35 | + -w, --working-directory <WORKING_DIRECTORY> |
| 36 | + -s, --sleep-time <SLEEP_TIME> [default: 5] |
| 37 | + -h, --help Print help |
| 38 | + -V, --version Print version |
| 39 | +``` |
| 40 | + |
| 41 | +## Configuration |
| 42 | + |
| 43 | +### Systemd |
| 44 | + |
| 45 | +```ini |
| 46 | +[Unit] |
| 47 | +Description=Magento 2 Worker Daemon |
| 48 | +After=network.target |
| 49 | + |
| 50 | +[Service] |
| 51 | +WorkingDirectory=/path/to/magento2 |
| 52 | +ExecStart=/usr/bin/magento2-worker-daemon |
| 53 | +Restart=always |
| 54 | + |
| 55 | +[Install] |
| 56 | +WantedBy=multi-user.target |
| 57 | +``` |
| 58 | + |
| 59 | +### Supervisor |
| 60 | + |
| 61 | +```ini |
| 62 | +[program:magento2-worker-daemon] |
| 63 | +directory=/path/to/magento2 |
| 64 | +command=/usr/bin/magento2-worker-daemon |
| 65 | +autostart=true |
| 66 | +autorestart=true |
| 67 | +stopsignal=INT |
| 68 | +stopasgroup=true |
| 69 | +``` |
| 70 | + |
| 71 | +## Work in progress |
| 72 | + |
| 73 | +This project is still a work in progress, and is not yet ready for production use. |
| 74 | + |
| 75 | +Things that still need to be done: |
| 76 | +- Add unit tests |
| 77 | +- Add proper signal handling (SIGTERM, SIGINT, SIGQUIT) |
| 78 | + - Currently, the daemon will only stop child processes when it receives a SIGINT |
0 commit comments