Opened 10 years ago
Last modified 8 years ago
#45803 new enhancement
mongodb @2.6.5_1: Run mongod instance with config file
Reported by: | moderndeveloperllc (Mark Garrett) | Owned by: | ryandesign (Ryan Carsten Schmidt) |
---|---|---|---|
Priority: | Normal | Milestone: | |
Component: | ports | Version: | |
Keywords: | Cc: | todofixthis (Phoenix) | |
Port: | mongodb |
Description
As indicated in the documentation, it is preferred to run the mongod instance via the config file, not command line parameters: http://docs.mongodb.org/manual/reference/program/mongod/#cmdoption--config
I've attached a sample mongod.conf file that replicates the existing options - plus one SSL option now mongodb compiles with --ssl
by default. I'm not sure how MacPorts handles default config files when installing or updating ports. I imagine that you would want to create mongod.conf
if it doesn't exist, but name it mongod-default.conf
if one does exist as to not overwrite user-defined parameters that might be needed for the instance to start.
Attachments (1)
Change History (8)
Changed 10 years ago by moderndeveloperllc (Mark Garrett)
Attachment: | mongod.conf added |
---|
comment:1 Changed 10 years ago by mf2k (Frank Schima)
Cc: | ryandesign@… removed |
---|---|
Owner: | changed from macports-tickets@… to ryandesign@… |
Version: | 2.3.2 |
comment:2 Changed 10 years ago by moderndeveloperllc (Mark Garrett)
Perhaps the port file could be changed to something like:
startupitem.executable sudo -u ${mongouser} ${prefix}/bin/mongod --config ${prefix}/etc/mongodb/mongodb.conf post-activate { if {![file exists ${prefix}/etc/mongodb/mongod.conf]} { file copy ${prefix}/etc/mongodb/mongod.conf.sample \ ${prefix}/etc/mongodb/mongod.conf } }
The above attached file replicates the existing startup item (with SSL added). Moving to config file would make it quite a bit easier for those of us who need to add other startup options.
comment:3 Changed 9 years ago by moderndeveloperllc (Mark Garrett)
Version 3 has the same config structure, so the above change should still work.
comment:4 Changed 9 years ago by todofixthis (Phoenix)
Cc: | phoenix.zerin@… added |
---|
comment:5 Changed 9 years ago by todofixthis (Phoenix)
Cc: | phoenix.zerin@… removed |
---|
Sorry for the noise; I did not realize that hitting the "CcMe!" button would also add a comment to the thread.
comment:6 Changed 8 years ago by todofixthis (Phoenix)
I'm trying to get this to work, but I'm running into an error that I'm not sure how to resolve.
I made the following changes:
https://github.com/todofixthis/macports-ports/commit/627f0f166bcf381bdfda39dcaedf054a0a7242ad
- Added
mongodb.conf.sample
to${portpath}/files
. - Added the following to
Portfile
:
post-activate { if {![file exists ${prefix}/etc/mongodb/mongodb.conf]} { file copy ${filespath}/mongodb.conf.sample \ ${prefix}/etc/mongodb/mongodb.conf } }
cd ${portpath}
sudo port install
This is the error that I get (note: /private/tmp/mongodb
is the directory containing the Portfile):
:debug:activate Executing proc-post-org.macports.activate-activate-0 :error:activate org.macports.activate for port mongodb returned: error copying "/private/tmp/mongodb/files/mongodb.conf.sample" to "/opt/local/etc/mongodb/mongodb.conf": no such file or directory :debug:activate Error code: NONE :debug:activate Backtrace: error copying "/private/tmp/mongodb/files/mongodb.conf.sample" to "/opt/local/etc/mongodb/mongodb.conf": no such file or directory while executing "proc-post-org.macports.activate-activate-0 org.macports.activate" ("eval" body line 1) invoked from within "eval $post $targetname" :info:activate Warning: targets not executed for mongodb: org.macports.activate
I confirmed that /private/tmp/mongodb/files/mongodb.conf.sample
does exist.
I think the error is indicating that it can't copy the file to /opt/local/etc/mongodb
because that directory doesn't exist, but even if I add xinstall -d ${prefix}/etc/mongodb
to the Portfile, I still get the same error.
I'm not sure how to continue; any ideas?
comment:7 Changed 8 years ago by todofixthis (Phoenix)
Cc: | todofixthis added |
---|
Sample mongod.conf file