简体   繁体   中英

How can I run composer post-install command in background?

How can I run a command in background inside composer script and go to next command. I tried something like below but It still hangs up until the chgrp command finishes and doesn't execute next command.

composer.json

"post-install-cmd": [
            "sh ./scripts/composer/post-install.sh"
 ],

post-install.sh

#!/bin/sh

set -ex

echo "Setting appropriate permissions"
nohup chgrp -R www web &
echo "Executing next command"

PHP is single threaded so running composer will lock it until the process is finished which means its still 'busy' when its running your shell script as it'll be waiting for that to finish.

However, it is possible to multithread it, but only from the CLI and it won't help you as you'll be starting proceedings from composer at the outset.

Have a look at this question and answers to see if it can be fit into your use case.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM