Question

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?

Était-ce utile?

La solution

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.

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top