Info
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.
Top User Comments
xgen-internal-githook commented on Tue, 20 May 2014 20:44:46 +0000:
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
mark.benvenuto commented on Wed, 2 Apr 2014 21:23:05 +0000:
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.
donnyv@gmail.com commented on Wed, 2 Apr 2014 20:50:37 +0000:
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?
mark.benvenuto commented on Wed, 2 Apr 2014 20:24:52 +0000:
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.