[SERVER-12502] When installing MongoDB as a Windows service, the --config argument is not quoted correctly if there are spaces in the path name Created: 28/Jan/14  Updated: 10/Dec/14  Resolved: 19/Mar/14

Status: Closed
Project: Core Server
Component/s: Admin
Affects Version/s: 2.4.9
Fix Version/s: None

Type: Bug Priority: Minor - P4
Reporter: Maurits Lourens Assignee: Mark Benvenuto
Resolution: Cannot Reproduce Votes: 0
Labels: Windows
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified
Environment:

Windows 7 Pro, SP1


Operating System: Windows
Steps To Reproduce:

1) Install MongoDB as a service using the following command
> mongod.exe --config "c:\Program Files\mongo\mongod.conf" --install
The service will install successfully.

2) Attempt the start the MongoDB service using net start
> net start "Mongo DB"

Participants:

 Description   

When installing MongoDB as a Windows Service, if the mongod.conf file is located in a path with spaces the service will not start correctly. Inspecting the ImagePath in the registry reveals that the --config path is not quoted correctly.

Steps to repro
1) Install MongoDB as a service using the following command
> mongod.exe --config "c:\Program Files\mongo\mongod.conf" --install
The service will install successfully.

2) Attempt the start the MongoDB service using net start
> net start "Mongo DB"
You'll receive "The service is not responding to the control function". Errors in System log from the Service Control Manager include "A timeout was reached (30000 milliseconds) while waiting for the Mongo DB service to connect" and "The Mongo DB service failed to start due to the following error: The service did not respond to the start or control request in a timely fashion."

Inspecting the ImagePath key in the registry at HKLM/System/CurrentControlSet/services/MongoDB/ImagePath reveals the following value:
"c:\mongo\bin\mongod.exe" --config c:\program files\mongo\mongod.conf --service

Note that the --config value is NOT quoted even though it was quoted on the command line when the service was installed.

The work around for this issue to simply to install the config file in a path without spaces, such as "c:\mongo\mongod.conf".

This issue is duplicate of https://jira.mongodb.org/browse/SERVER-5275 and https://jira.mongodb.org/browse/SERVER-4410. I created this issue again, because that issue has been closed, but it still happening with a later version.



 Comments   
Comment by Stennie Steneker (Inactive) [ 19/Mar/14 ]

Hi Maurits,

Given that we have thus far been unable to reproduce this issue, I'm going to close it out.

If you have any further information that would help us reproduce the problem, please let us know.

Thanks,
Stephen

Comment by Mark Benvenuto [ 28/Jan/14 ]

When I try your repro on 2.4.9, I get the following error:
> mongod--install --config "c:\Program Files\mongo\mongod.conf"
Tue Jan 28 13:42:53.365 --install has to be used with --logpath

When I fix your example, the issue does not repro for me in 2.4.9.
D:\some log path>mongod --install --config "c:\Program Files\mongo\mongod.conf" --logpath "d:\some log path\log3.log"
Tue Jan 28 13:41:17.981 Trying to install Windows service 'MongoDB'
Tue Jan 28 13:41:17.985 Service 'MongoDB' (Mongo DB) installed with command line '"D:\some log path\mongod.exe" --config "c:\Program Files\mongo\mongod.conf"
--logpath "d:\some log path\log3.log" --service'
Tue Jan 28 13:41:17.985 Service can be started from the command line with 'net start MongoDB'

It also is correct in the registry:
reg query HKLM\System\CurrentControlSet\services\MongoDB\

HKEY_LOCAL_MACHINE\System\CurrentControlSet\services\MongoDB
Type REG_DWORD 0x10
Start REG_DWORD 0x2
ErrorControl REG_DWORD 0x1
ImagePath REG_EXPAND_SZ "D:\some log path\mongod.exe" --config "c:\Program Files\mongo\mongod.conf" --logpath "d:\some log path\log3.log" --service

DisplayName REG_SZ Mongo DB
ObjectName REG_SZ LocalSystem
Description REG_SZ Mongo DB Server

Generated at Thu Feb 08 03:28:42 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.