private void StartDB() { _('c', "Starting server process..."); try { pMongo = new ProcessCaller(this); pMongo.FileName = mongoBin; pMongo.Arguments = "--dbpath " + mongoData; pMongo.StdErrReceived += writeStreamInfo; pMongo.StdOutReceived += writeStreamInfo; pMongo.Completed += processCompletedOrCanceled; pMongo.Cancelled += processCompletedOrCanceled; pMongo.Start(); UpdateStatus(true); } catch (Exception x) { _('c', String.Format("Error when trying to start MongoDB server process: {0}\r\n", x.Message)); _('c', String.Format("Path to server binary: {0}\r\n", mongoBin)); _('c', String.Format("Path to data folder: {0}\r\n", mongoData)); pMongo = null; UpdateStatus(false); } }
private void RepairDB() { if (mongoRunning) { _('c', "Database is running. Trying to stop..."); StopDB(); if (!pMongo.process.WaitForExit(5000)) { _('c', "Timed out while waiting for process to terminate. Killing."); pMongo.process.Kill(); } } _('c', "Starting database repair..."); try { var pc = new ProcessCaller(this); pc.FileName = mongoBin; pc.Arguments = "--dbpath " + mongoData + " --repair"; pc.StdErrReceived += writeStreamInfo; pc.StdOutReceived += writeStreamInfo; pc.Completed += processCompletedOrCanceled; pc.Cancelled += processCompletedOrCanceled; pc.Start(); UpdateStatus(true); } catch (Exception x) { _('c', String.Format("Error when trying to start MongoDB repair process: {0}\r\n", x.Message)); _('c', String.Format("Path to server binary: {0}\r\n", mongoBin)); _('c', String.Format("Path to data folder: {0}\r\n", mongoData)); pMongo = null; UpdateStatus(false); } }