brew/mongodb doesn't stop when I close terminal

0

I installed mongodb with brew and I didn't load the launchctl plist.

When I run the mongod command to start the server in foreground and suddenly close my iTerm the mongodb process stays up and I don't want that.

Why is this? How can I avoid it?

kilianc

Posted 2014-07-13T17:11:22.527

Reputation: 101

Answers

1

Exit the process before you close the terminal. You can do this by pressing Ctrl-C. It's somewhat odd that iTerm is not killing processes when you close tabs/windows - it's supposed to, but some Googling suggest you are not the only one to see this issue (I didn't see an obvious solution for it).

If you forget to Ctrl-C and the mongod is still hanging around after the close, just find the process and kill it:

ps aux | grep mongod
# get the pid of the process from the above command
kill <PID>

Or, for a one liner:

kill $(pidof mongod)

MongoDB will exit normally when you do use a regular kill, so no worries on that front.

Adam C

Posted 2014-07-13T17:11:22.527

Reputation: 2 475

I see but the problem is not related to iTerm and ZSH, I used terminal.app and bash and same thing happens. I don't understand how the process keeps running with my session being closes, I think it's somehow something related to mongodb itself.. – kilianc – 2014-07-14T17:00:58.810