Exemplo n.º 1
0
        /// <summary>
        ///     生成Ini格式Config文件
        /// </summary>
        /// <returns></returns>
        public static string GenerateIniFile(MongodConfig mongod)
        {
            //http://www.mongodb.org/display/DOCS/File+Based+SystemManager(无法阅览,自动跳到下面这个链接)
            //http://docs.mongodb.org/manual/reference/configuration-options/
            //http://www.cnblogs.com/think-first/archive/2013/03/22/2976553.html
            //Location of the database files

            var strIni = "#Basic database configuration" + Environment.NewLine;

            if (mongod.DbPath != string.Empty)
            {
                strIni += "#Location of the database files   " + Environment.NewLine;
                strIni += "dbpath = " + mongod.DbPath + Environment.NewLine;
            }

            if (mongod.Port != 0)
            {
                strIni += "#Port the mongod will listen on  " + Environment.NewLine;
                strIni += "port = " + mongod.Port + Environment.NewLine;
            }

            strIni += "#Specific IP address that mongod will listen on  " + Environment.NewLine;
            if (mongod.BindIp != string.Empty)
            {
                strIni += "bind_ip  = " + mongod.BindIp + Environment.NewLine;
            }
            else
            {
                strIni += "bind_ip = 127.0.0.1" + Environment.NewLine;
            }

            if (mongod.LogPath != string.Empty)
            {
                strIni += "#Full filename path to where log messages will be written  " + Environment.NewLine;
                strIni += "logpath = " + mongod.LogPath + Environment.NewLine;
            }

            strIni += "#Full filename path to where log messages will be written  " + Environment.NewLine;
            if (mongod.Islogappend)
            {
                strIni += "logappend = true" + Environment.NewLine;
            }
            else
            {
                strIni += "logappend = false " + mongod.LogPath + Environment.NewLine;
            }

            return(strIni);
        }
Exemplo n.º 2
0
        /// <summary>
        /// </summary>
        /// <returns></returns>
        public static string GenerateIniFile(MongodConfig mongod)
        {
            //http://www.mongodb.org/display/DOCS/File+Based+SystemManager(无法阅览,自动跳到下面这个链接)
            //http://docs.mongodb.org/manual/reference/configuration-options/
            //http://www.cnblogs.com/think-first/archive/2013/03/22/2976553.html
            //Location of the database files 

            var strIni = "#Basic database configuration" + Environment.NewLine;

            if (mongod.DbPath != string.Empty)
            {
                strIni += "#Location of the database files   " + Environment.NewLine;
                strIni += "dbpath = " + mongod.DbPath + Environment.NewLine;
            }

            if (mongod.Port != 0)
            {
                strIni += "#Port the mongod will listen on  " + Environment.NewLine;
                strIni += "port = " + mongod.Port + Environment.NewLine;
            }

            strIni += "#Specific IP address that mongod will listen on  " + Environment.NewLine;
            if (mongod.BindIp != string.Empty)
            {
                strIni += "bind_ip  = " + mongod.BindIp + Environment.NewLine;
            }
            else
            {
                strIni += "bind_ip = 127.0.0.1" + Environment.NewLine;
            }

            if (mongod.LogPath != string.Empty)
            {
                strIni += "#Full filename path to where log messages will be written  " + Environment.NewLine;
                strIni += "logpath = " + mongod.LogPath + Environment.NewLine;
            }

            strIni += "#Full filename path to where log messages will be written  " + Environment.NewLine;
            if (mongod.Islogappend)
            {
                strIni += "logappend = true" + Environment.NewLine;
            }
            else
            {
                strIni += "logappend = false " + mongod.LogPath + Environment.NewLine;
            }

            return strIni;
        }
Exemplo n.º 3
0
        /// <summary>
        ///     部署
        /// </summary>
        public static string GetMongodCommandLine(MongodConfig mongod)
        {
            //mongo.exe 客户端程序
            var dosCommand = @"mongod --dbpath @dbpath --port @port ";

            //数据库路径
            dosCommand = dosCommand.Replace("@dbpath", "\"" + mongod.DbPath + "\"");
            //端口号
            dosCommand = dosCommand.Replace("@port", mongod.Port.ToString());
            //日志文件
            if (mongod.LogPath != string.Empty)
            {
                dosCommand += " --logpath \"" + mongod.LogPath + "\"";
                switch (mongod.LogLv)
                {
                case MongologLevel.Quiet:
                    dosCommand += " --quiet ";
                    break;

                case MongologLevel.V:
                    dosCommand += " --verbose ";
                    break;

                case MongologLevel.Vv:
                    dosCommand += " --vv ";
                    break;

                case MongologLevel.Vvv:
                    dosCommand += " --vvv ";
                    break;

                case MongologLevel.Vvvv:
                    dosCommand += " --vvvv ";
                    break;

                case MongologLevel.Vvvvv:
                    dosCommand += " --vvvvv ";
                    break;
                }
                //日志是否为添加模式
                if (mongod.Islogappend)
                {
                    dosCommand += " --logappend ";
                }
            }
            //是否为Master
            if (mongod.Master)
            {
                dosCommand += " --master";
            }
            if (mongod.Slave)
            {
                dosCommand += " --slave";
                if (mongod.Source != string.Empty)
                {
                    dosCommand += " --source " + mongod.Source;
                }
            }
            //是否作为Windows服务
            if (mongod.IsInstall)
            {
                dosCommand += " --install";
            }
            //是否使用认证服务
            if (mongod.IsAuth)
            {
                dosCommand += " --auth";
            }
            return(dosCommand);
        }
Exemplo n.º 4
0
 /// <summary>
 ///     部署
 /// </summary>
 public static string GetMongodCommandLine(MongodConfig mongod)
 {
     //mongo.exe 客户端程序
     var dosCommand = @"mongod --dbpath @dbpath --port @port ";
     //数据库路径
     dosCommand = dosCommand.Replace("@dbpath", "\"" + mongod.DbPath + "\"");
     //端口号
     dosCommand = dosCommand.Replace("@port", mongod.Port.ToString());
     //日志文件
     if (mongod.LogPath != string.Empty)
     {
         dosCommand += " --logpath \"" + mongod.LogPath + "\"";
         switch (mongod.LogLv)
         {
             case MongologLevel.Quiet:
                 dosCommand += " --quiet ";
                 break;
             case MongologLevel.V:
                 dosCommand += " --verbose ";
                 break;
             case MongologLevel.Vv:
                 dosCommand += " --vv ";
                 break;
             case MongologLevel.Vvv:
                 dosCommand += " --vvv ";
                 break;
             case MongologLevel.Vvvv:
                 dosCommand += " --vvvv ";
                 break;
             case MongologLevel.Vvvvv:
                 dosCommand += " --vvvvv ";
                 break;
         }
         //日志是否为添加模式
         if (mongod.Islogappend)
         {
             dosCommand += " --logappend ";
         }
     }
     //是否为Master
     if (mongod.Master)
     {
         dosCommand += " --master";
     }
     if (mongod.Slave)
     {
         dosCommand += " --slave";
         if (mongod.Source != string.Empty)
         {
             dosCommand += " --source " + mongod.Source;
         }
     }
     //是否作为Windows服务
     if (mongod.IsInstall)
     {
         dosCommand += " --install";
     }
     //是否使用认证服务
     if (mongod.IsAuth)
     {
         dosCommand += " --auth";
     }
     return dosCommand;
 }