[SERVER-13463] Relative path in config file for mongod.exe not working when installing window service Created: 02/Apr/14  Updated: 08/Feb/23  Resolved: 20/May/14

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

Type: Bug Priority: Minor - P4
Reporter: Donny V Assignee: Mark Benvenuto
Resolution: Done Votes: 0
Labels: configuration, windows
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified
Environment:

Windows 7 64bit & Windows Server 2008 R2 SP1 64bit


Attachments: File MongoDB_windowsService.config    
Issue Links:
Depends
is depended on by SERVER-13412 "--dbpath not set" error message is u... Closed
Related
related to SERVER-14842 Relative path allowed for auditPath w... Closed
related to SERVER-21615 basisTechRootDirectory option should ... Closed
related to SERVER-21614 kmip*File options should forbid relat... Backlog
Operating System: Windows
Sprint: Server 2.7.2
Participants:

 Description   

When I try to create a windows service with a config file that
has a relative database path. It lets me create the service but it
won't start. If I use the same config file to run mongo in a console it works
fine.



 Comments   
Comment by Githook User [ 20/May/14 ]

Author:

{u'username': u'markbenvenuto', u'name': u'Mark Benvenuto', u'email': u'mark.benvenuto@mongodb.com'}

Message: SERVER-13463: Option Validation for NT Services

The current working directory for NT Services differs between installation time
and execution time. This leads to subtle user bugs where the service can fail to
start because directories do not exist. In the worst situation, the log file
directory may not exist which makes the debugging near impossible.
Branch: master
https://github.com/mongodb/mongo/commit/650c98468737c2ae9aa7f278111e863276c79e55

Comment by Mark Benvenuto [ 02/Apr/14 ]

Relative paths are sensitive to the current working directory. With NT Services, the current working directory varies between installation time (i.e., it may be c:\mongo as an example) while during service execution time it will be c:\windows\system32 (as an example). This means that during installation time of the service, your data directory may be "c:\mongo\data\db" (if you ran it from c:\mongo) but during service execution time it would be "c:\windows\system32\data\db" because the current working directories differ.

Comment by Donny V [ 02/Apr/14 ]

Not sure why setting the relative path for the database and log folder should effect how the service gets created.
Why not treat them separately?

Comment by Mark Benvenuto [ 02/Apr/14 ]

The working directory for an NT Service is %WINDIR%\System32 instead of the directory where you ran the --install command. This is why the relative paths in the config file failed. Use an absolute to path (d:\log, etc) to fix this.

In the future, we will likely error to prevent problems in the future.

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