문제

I running mongodb instance from bash scripts and I need to show user-friendly message if mogngo will crash during startup for some reason.

so I have that sort of code

eval 'mongod --dbpath=$ABS_MONGO_DATA_PATH &' || printf "something bad happened"

but with that sort of notation error handler never called. But if I remove & sing, then after mongo initialization further script do not running because of mongod process waiting for a signals

How could I resolve that issue?

도움이 되었습니까?

해결책

You don't need eval for this:

{ mongod --dbpath="$ABS_MONGO_DATA_PATH" ||
   printf "something bad happened"; } &

Instead of just running mongod in the background, run the entire command list in the background.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top