Example #1
0
        /// <summary>
        /// Starts the
        /// </summary>
        public bool Start(bool waitOnStartup = true, TimeSpan?timeout = null)
        {
            bool res = false;

            if (_starter == null)
            {
                int?port;
                if (AutoPort)
                {
                    do
                    {
                        port = 35000 + _rnd.Next(10, 60);
                    } while (!PortUtils.TestPort(port.Value));
                    Configuration.Parameters.ServerPort = string.Format("localhost:{0}", port.Value);
                    Configuration.SaveConfigFile();
                }
                else
                {
                    port = PortUtils.GetPort(_config.Parameters.ServerPort);
                    if (!port.HasValue)
                    {
                        throw new ArgumentException("No valid port given.");
                    }
                }

                _config.Locked = true;

                string param = "";
                if (Environment.OSVersion.Platform == PlatformID.Unix || Environment.OSVersion.Platform == PlatformID.MacOSX)
                {
                    _starter = new UnixVirtuosoStarter(port.Value, _binary.Directory, _configFile.Directory);
                    param    = string.Format("-f -c \"{0}\"", _configFile.FullName);
                }
                else
                {
                    _starter = new Win32VirtuosoStarter(port.Value, _binary.Directory, _configFile.Directory);
                    param    = string.Format("-f -c \"{0}\"", _configFile.FullName);
                }

                _starter.Executable = _binary.FullName;
                _starter.Parameter  = param;
                res = _starter.Start(waitOnStartup, timeout);
            }
            return(res);
        }