John Jai
John Jai

Reputation: 3723

Shutdown MongoDB on Gradle

I am trying to execute below shutdown command via Gradle to the mongo.exe.

C:\mongodb-2.6-standard\bin>mongo admin --eval db.shutdownServer()
MongoDB shell version: 2.6.5
connecting to: admin
2014-12-10T11:57:14.126-0700 DBClientCursor::init call() failed
server should be down...

Gradle executable:

task stopMongo(type: Exec) {
    println 'stop Mongo'

    workingDir 'mongo'
    executable 'mongo/mongo.exe'
    args 'admin', '--eval db.shutdownServer()'
}

But I am getting below error when executing the stopMongo task.

Error parsing command line: unknown option --eval db.shutdownServer()

If I do remove the -- from eval in gradle, then it's getting connected to mongodb, but with below error:

MongoDB shell version: 2.6.5
connecting to: admin
2014-12-10T12:05:41.765-0700 file [eval db.shutdownServer()] doesn't exist

Upvotes: 1

Views: 243

Answers (1)

Opal
Opal

Reputation: 84786

Have You tried:

'--eval', 'db.shutdownServer()'

Command-line arguments should be always passed separately.

Upvotes: 3

Related Questions