FriendsOfShopware / shopware-cli

CLI for Shopware Account and Shopware 6
MIT License
84 stars 32 forks source link

shopware-cli doesn't kill subprocesses when stopping #389

Closed pkramme closed 3 months ago

pkramme commented 4 months ago

PHP Version

8.0-8.3

Shopware Version

6.4-6.6

Plugin Version

0.4.48

Actual behaviour

When shopware-cli stops expectedly or unexpectedly, subprocesses are orphaned and are continuing to run. This can create situations, where many more worker run than configured.

hubble_+  652966  0.1  0.1 1251256 21120 ?       Sl   13:22   0:00  \_ /usr/bin/shopware-cli project worker 3 --memory-limit=2G
hubble_+  652979 11.1  0.6 176224 109932 ?       S    13:22   0:00      \_ php bin/console messenger:consume --memory-limit=2G --time-limit=120 async failed
hubble_+  652980  7.5  0.6 174176 109904 ?       S    13:22   0:00      \_ php bin/console messenger:consume --memory-limit=2G --time-limit=120 async failed
hubble_+  652981 11.5  0.6 163936 99740 ?        S    13:22   0:00      \_ php bin/console messenger:consume --memory-limit=2G --time-limit=120 async failed
hubble_+  652951  6.2  0.6 178272 114064 ?       S    13:22   0:00 php bin/console messenger:consume --memory-limit=2G --time-limit=120 async failed
hubble_+  652950  8.8  0.6 174176 110304 ?       S    13:22   0:01 php bin/console messenger:consume --memory-limit=2G --time-limit=120 async failed
hubble_+  652923 13.9  0.7 188512 124780 ?       S    13:21   0:02 php bin/console messenger:consume --memory-limit=2G --time-limit=120 async failed
hubble_+  652921  8.2  0.7 180320 116436 ?       S    13:21   0:01 php bin/console messenger:consume --memory-limit=2G --time-limit=120 async failed
hubble_+  652866 10.0  0.7 190560 126968 ?       S    13:21   0:03 php bin/console messenger:consume --memory-limit=2G --time-limit=120 async failed
hubble_+  652865 10.6  0.7 194656 129972 ?       S    13:21   0:04 php bin/console messenger:consume --memory-limit=2G --time-limit=120 async failed
hubble_+  652748  6.1  0.8 199268 133976 ?       S    13:21   0:04 php bin/console messenger:consume --memory-limit=2G --time-limit=120 async failed
hubble_+  652704  7.6  0.8 208992 145092 ?       S    13:21   0:05 php bin/console messenger:consume --memory-limit=2G --time-limit=120 async failed
hubble_+  652701  5.6  0.7 184416 120748 ?       S    13:21   0:04 php bin/console messenger:consume --memory-limit=2G --time-limit=120 async failed
hubble_+  652650  8.6  0.7 192608 128236 ?       S    13:20   0:07 php bin/console messenger:consume --memory-limit=2G --time-limit=120 async failed
hubble_+  652649  7.0  0.8 209508 145324 ?       S    13:20   0:06 php bin/console messenger:consume --memory-limit=2G --time-limit=120 async failed
hubble_+  652609  8.3  0.8 207460 143680 ?       S    13:20   0:07 php bin/console messenger:consume --memory-limit=2G --time-limit=120 async failed
hubble_+  652567  7.5  0.8 206944 143228 ?       S    13:20   0:07 php bin/console messenger:consume --memory-limit=2G --time-limit=120 async failed
hubble_+  652471  7.1  0.8 198752 134208 ?       S    13:20   0:07 php bin/console messenger:consume --memory-limit=2G --time-limit=120 async failed
hubble_+  652417  7.4  0.8 209508 144516 ?       R    13:20   0:09 php bin/console messenger:consume --memory-limit=2G --time-limit=120 async failed

Expected behaviour

shopware-cli should make an effort to kill subprocesses and wait for them to actually stop before quitting itself.

Steps to Reproduce?

/usr/bin/shopware-cli project worker 3 --memory-limit=2G
# kill shopware-cli
ps auxf | grep messenger
# see still running subprocesses, now orphaned
pkramme commented 3 months ago

fix in #394