[SERVER-6032] Windows service fails to start Created: 07/Jun/12  Updated: 15/Feb/13  Resolved: 20/Aug/12

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

Type: Bug Priority: Major - P3
Reporter: Travis Paxton Assignee: Tad Marshall
Resolution: Done Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified
Environment:

Windows 7 64-bit


Operating System: Windows
Participants:

 Description   

When I try to start the MongoDB service, I get the following:

  • <Event xmlns="http://schemas.microsoft.com/win/2004/08/events/event">
  • <System>
    <Provider Name="Service Control Manager" Guid=" {555908d1-a6d7-4695-8e1e-26931d2012f4}

    " EventSourceName="Service Control Manager" />
    <EventID Qualifiers="49152">7031</EventID>
    <Version>0</Version>
    <Level>2</Level>
    <Task>0</Task>
    <Opcode>0</Opcode>
    <Keywords>0x8080000000000000</Keywords>
    <TimeCreated SystemTime="2012-06-07T15:07:20.102638700Z" />
    <EventRecordID>29174</EventRecordID>
    <Correlation />
    <Execution ProcessID="684" ThreadID="3040" />
    <Channel>System</Channel>
    <Computer>15z</Computer>
    <Security />
    </System>

  • <EventData>
    <Data Name="param1">Mongo DB</Data>
    <Data Name="param2">1</Data>
    <Data Name="param3">0</Data>
    <Data Name="param4">1</Data>
    <Data Name="param5">Restart the service</Data>
    </EventData>
    </Event>

I created the service using: C:\mongodb\bin\mongod.exe --install --dbpath=..\db --logpath=..\mongo.log --logappend -vvvvv

When I run directly from the cmd console, it works fine.



 Comments   
Comment by Tad Marshall [ 20/Aug/12 ]

The "current working directory" of processes started by the Windows Service Control Manager will be C:\Windows\System32, so your dbpath of ..\db will be resolved as C:\Windows\db and your logpath will be resolved as C:\Windows\mongo.log.

When I test your command on my system, the log file at C:\Windows\mongo.log is written and it contains this text:

Mon Aug 20 09:45:41 BackgroundJob starting: DataFileSync
Mon Aug 20 09:45:41 Trying to start Windows service 'MongoDB'
Mon Aug 20 09:45:41 Service running
Mon Aug 20 09:45:41 [initandlisten] MongoDB starting : pid=4948 port=27017 dbpath=..\db 64-bit host=MissLucy
Mon Aug 20 09:45:41 [initandlisten]
Mon Aug 20 09:45:41 [initandlisten] ** NOTE: This is a development version (2.3.0-pre-) of MongoDB.
Mon Aug 20 09:45:41 [initandlisten] **       Not recommended for production.
Mon Aug 20 09:45:41 [initandlisten]
Mon Aug 20 09:45:41 [initandlisten] db version v2.3.0-pre-, pdfile version 4.5
Mon Aug 20 09:45:41 [initandlisten] git version: 37bf8f163db4d04b5bb7c175f7705e3837b48751
Mon Aug 20 09:45:41 [initandlisten] build info: windows sys.getwindowsversion(major=6, minor=1, build=7601, platform=2, service_pack='Service Pack 1') BOOST_LIB_VERSION=1_49
Mon Aug 20 09:45:41 [initandlisten] options: { dbpath: "..\db", logappend: true, logpath: "..\mongo.log", service: true, vvvvv: true }
Mon Aug 20 09:45:41 [initandlisten] User Assertion: 10296:
*********************************************************************
 ERROR: dbpath (..\db) does not exist.
 Create this directory or give existing directory in --dbpath.
 See http://dochub.mongodb.org/core/startingandstoppingmongo
*********************************************************************
 
Mon Aug 20 09:45:41 [initandlisten] exception in initAndListen: 10296
*********************************************************************
 ERROR: dbpath (..\db) does not exist.
 Create this directory or give existing directory in --dbpath.
 See http://dochub.mongodb.org/core/startingandstoppingmongo
*********************************************************************
, terminating
Mon Aug 20 09:45:41 dbexit:
Mon Aug 20 09:45:41 [initandlisten] shutdown: going to close listening sockets...
Mon Aug 20 09:45:41 [initandlisten] shutdown: going to flush diaglog...
Mon Aug 20 09:45:41 [initandlisten] shutdown: going to close sockets...
Mon Aug 20 09:45:41 [initandlisten] shutdown: waiting for fs preallocator...
Mon Aug 20 09:45:41 [initandlisten] shutdown: lock for final commit...
Mon Aug 20 09:45:41 [initandlisten] shutdown: final commit...
Mon Aug 20 09:45:41 [initandlisten] shutdown: closing all files...
Mon Aug 20 09:45:41 [initandlisten] closeAllFiles() finished
Mon Aug 20 09:45:41 [initandlisten] shutdown: groupCommitMutex
Mon Aug 20 09:45:41 dbexit: really exiting now

If I create the directory C:\Windows\db, the service will start, but this is not a good place for a database directory.

It would probably be better if mongod.exe had resolved the relative path to an absolute path at the time that you ran the --install command and then used an absolute path in the command line stored for starting the service. Feel free to file a Jira ticket suggesting this, or let me know and I can do it.

Comment by Tad Marshall [ 07/Jun/12 ]

The --dbpath=..\db and --logpath=..\mongo.log will try to use relative directories based on the current directory of the service process, which may not be the intended location (and the location may not exist). Can you use fully-qualified paths and change "--install" to "--reinstall" and see if that fixes it? For example:

C:\mongodb\bin\mongod.exe --reinstall --dbpath=C:\mongodb\db --logpath=C:\mongodb\mongo.log --logappend -vvvvv

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