I was working with a microservice project, so I needed to run all services at once so I set up bash script but throw stdin is not a tty error and run only the last line of command
yarn --cwd /d/offic_work/server/customer/ start:dev &
yarn --cwd /d/offic_work/server/admin start:dev &
yarn --cwd /d/offic_work/server/orders/ start:dev &
yarn --cwd /d/offic_work/server/product start:dev
CodePudding user response:
Try to add & for each command
CodePudding user response:
I'm not particularly familiar with yarn, but "is not a tty" means it is seeking input from the user, and can't get any because you ran it in the background. So what you need to do is run it in the foreground, find out what input it is seeking, then figure out what command line arguments, or otherwise configuration will let it run without user intervention. Then when you know that you can alter your script or take appropriate action so that it can run in the background.
In some cases, programs expect a user confirmation "y" to some question. That's why in unix the "yes" command exists, which outputs endless "y"s for such a purpose. You could also try piping yes to your command:
yes | yarn --cwd /d/offic_work/server/customer/ start:dev &
CodePudding user response:
first
Create a list of your services i.e. list.txt
customer
admin
orders
product
second
Run them in parallel with xargs -P 0
# dry-run - test
xargs -I SERVICE -P 0 echo "yarn --cwd /d/offic_work/server/SERVICE start:dev" < list.txt
# run - remove the echo
xargs -I SERVICE -P 0 yarn --cwd /d/offic_work/server/SERVICE start:dev < list.txt