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?

Was it helpful?

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.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top