gcollazo / mongodbapp

The easiest way to get started with MongoDB on the Mac
http://gcollazo.github.io/mongodbapp
MIT License
521 stars 38 forks source link

Allow user to create their own mongo config file #8

Closed mjaustin2 closed 1 year ago

mjaustin2 commented 8 years ago

Sorry, I'm too lazy to fork and create a pull request for a 7 line change, but would be nice if the user could have their own mongodb.conf to configure options.

The code below changes startServer to check for a file in the user home directory, and if found add it to the command arguments.

Full File attached: AppDelegate

    func startServer() {
        self.task = NSTask()
        self.pipe = NSPipe()
        self.file = self.pipe.fileHandleForReading

        if let path = NSBundle.mainBundle().pathForResource("mongod", ofType: "", inDirectory: "Vendor/mongodb") {
            self.task.launchPath = path
        }

        var args = ["--dbpath", self.dataPath, "--nounixsocket", "--logpath", "\(self.logPath)/mongo.log"]

        // Check if user config file exists and add to arguments (~/.mongodb.conf)
        let configFile = (NSHomeDirectory() + "/.mongodb.conf")
        let fileManager = NSFileManager.defaultManager()
        if fileManager.fileExistsAtPath(configFile) {
            args.append("--config")
            args.append(configFile)
        }

        self.task.arguments = args
        self.task.standardOutput = self.pipe

        print("Run mongod")

        self.task.launch()
    }
mjaustin2 commented 8 years ago

Not even a comment to tell me how bad my code is? :-)

gcollazo commented 8 years ago

Hi there. Couldn't review this before. I will try to test it soon. A PR will make it much easier for me.

arciisine commented 7 years ago

Any update on this? I'm running into the same issue, and it would be nice to configure this.

gcollazo commented 7 years ago

Hi @arciisine. I haven't been able to try this out. This is not a feature I personally use. I would be willing to merge a pull request that worked.

makan1869 commented 7 years ago

I tried to fix this, but mainly I have another problem here, binding IP Address and dbPath is configured in the command line argument, so whatever config I pass here will be overwritten.

juliangrigera commented 7 years ago

There, I fixed it and made a PR. As @makan1869 correctly says, the command line arguments at launch would override the file settings, so those needed to be replaced with the file's values. Disclaimer: this is the first Swift code that I ever write so go easy on it & let me know whatever needs to be fixed!

amcgregor commented 2 years ago

I would recommend something more UNIX-y, such as ~/.local/etc/mongod.conf, or, more macOS-y, such as ~/Library/Preferences/io.blimp.MongoDB.conf to go alongside the existing io.blimp.MongoDB.plist used for actual GUI application preferences/cookies. (Edit to note: my dotfiles are already cluttered enough at the top level. 😜)

I, too, ran into this need, in order to specify storage:directoryPerDB:. An alternative that would satisfy my requirements would be the ability to specify additional command-line arguments, --directoryperdb, of which -f [ --config ] arg to specify a configuration file explicitly would satisfy this issue as well.

8 month update: Now I have a need to apply a tweak to wiredTiger.engineConfig.cacheSizeGB