Beispiel #1
0
        /// <summary>
        /// Application entry point.
        /// </summary>
        internal static void Main(string[] args)
        {
            try
            {
                // Check for special cases.
                if (args.Length > 0)
                {
                    string first = args[0].ToLowerInvariant();

                    if (Help.Contains(first))
                    {
                        ConsoleUtils.PrintHelp("Apache.Ignite.dll", false);

                        return;
                    }
                }

                // Pick application configuration first, command line arguments second.
                var allArgs = AppSettingsConfigurator.GetArgs(ConfigurationManager.AppSettings)
                              .Concat(ArgsConfigurator.GetArgs(args)).ToArray();

                var ignite = Ignition.Start(Configurator.GetConfiguration(allArgs));

                // Wait until stopped.
                var evt = new ManualResetEventSlim(false);
                ignite.Stopped += (s, a) => evt.Set();
                evt.Wait();
            }
            catch (Exception e)
            {
                Console.WriteLine("ERROR: " + e);

                Environment.Exit(-1);
            }
        }
Beispiel #2
0
        /// <summary>
        /// Application entry point.
        /// </summary>
        internal static void Main(string[] args)
        {
            bool svc     = false;
            bool install = false;

            try
            {
                // Check for special cases.
                if (args.Length > 0)
                {
                    string first = args[0].ToLowerInvariant();

                    if (Help.Contains(first))
                    {
                        PrintHelp();

                        return;
                    }

                    if (Svc.Equals(first))
                    {
                        args = RemoveFirstArg(args);

                        svc = true;
                    }

                    else if (SvcInstall.Equals(first))
                    {
                        args = RemoveFirstArg(args);

                        install = true;
                    }
                    else if (SvcUninstall.Equals(first))
                    {
                        IgniteService.Uninstall();

                        return;
                    }
                }

                if (!svc)
                {
                    // Pick application configuration first, command line arguments second.
                    var allArgs = AppSettingsConfigurator.GetArgs(ConfigurationManager.AppSettings)
                                  .Concat(ArgsConfigurator.GetArgs(args)).ToArray();

                    if (install)
                    {
                        IgniteService.DoInstall(allArgs);
                    }
                    else
                    {
                        var ignite = Ignition.Start(Configurator.GetConfiguration(allArgs));

                        // Wait until stopped.
                        var evt = new ManualResetEventSlim(false);
                        ignite.Stopped += (s, a) => evt.Set();
                        evt.Wait();
                    }

                    return;
                }
            }
            catch (Exception e)
            {
                Console.WriteLine("ERROR: " + e);

                Environment.Exit(-1);
            }

            // If we are here, then this is a service call.
            // Use only arguments, not app.config.
            var cfg = Configurator.GetConfiguration(ArgsConfigurator.GetArgs(args).ToArray());

            ServiceBase.Run(new IgniteService(cfg));
        }
Beispiel #3
0
        internal static void Main(string[] args)
        {
            bool svc     = false;
            bool install = false;

            try
            {
                // Check for special cases.
                if (args.Length > 0)
                {
                    string first = args[0].ToLowerInvariant();

                    if (Help.Contains(first))
                    {
                        ConsoleUtils.PrintHelp("Apache.Ignite.exe", true);

                        return;
                    }

                    if (Svc.Equals(first, StringComparison.Ordinal))
                    {
                        args = RemoveFirstArg(args);

                        svc = true;
                    }

                    else if (SvcInstall.Equals(first, StringComparison.Ordinal))
                    {
                        args = RemoveFirstArg(args);

                        install = true;
                    }
                    else if (SvcUninstall.Equals(first, StringComparison.Ordinal))
                    {
                        IgniteService.Uninstall();

                        return;
                    }
                }

                if (!svc)
                {
                    // Pick application configuration first, command line arguments second.
                    var allArgs = AppSettingsConfigurator.GetArgs(ConfigurationManager.AppSettings)
                                  .Concat(ArgsConfigurator.GetArgs(args))
                                  .ToArray();

                    if (install)
                    {
                        IgniteService.DoInstall(allArgs);
                    }
                    else
                    {
                        // Load assemblies before instantiating IgniteConfiguration,
                        // it can reference types from those assemblies.
                        allArgs = allArgs.LoadAssemblies().ToArray();

                        using (var ignite = Ignition.Start(Configurator.GetConfiguration(allArgs)))
                        {
                            // Wait until stopped.
                            using (var evt = new ManualResetEventSlim(false))
                            {
                                ignite.Stopped         += (s, a) => evt.Set();
                                Console.CancelKeyPress += (s, a) => evt.Set();
                                evt.Wait();
                            }
                        }
                    }

                    return;
                }
            }
            catch (Exception e)
            {
                Console.WriteLine("ERROR: " + e);

                Environment.Exit(-1);
            }

            // If we are here, then this is a service call.
            // Use only arguments, not app.config.
            var cfg = Configurator.GetConfiguration(ArgsConfigurator.GetArgs(args).ToArray());

            IgniteService.Run(cfg);
        }
Beispiel #4
0
        private static async Task StartServerAsync(string[] args) //string[] args
        {
            try
            {
                if (args != null && args.Length > 0 && IGNITE_SERVER == null)
                {
                    Tuple <string, string>[] array = AppSettingsConfigurator.GetArgs(ConfigurationManager.AppSettings).Concat <Tuple <string, string> >(ArgsConfigurator.GetArgs((IEnumerable <string>)args)).ToArray <Tuple <string, string> >();

                    // Connect to the cluster.
                    IGNITE_SERVER = Ignition.Start(Configurator.GetConfiguration(array)); //configuration //"server-config.xml" //Configurator.GetConfiguration(array)
                    // Activate the cluster.
                    // This is required only if the cluster is still inactive.
                    IGNITE_SERVER.GetCluster().SetActive(true);

                    IEnumerable <IClusterNode> nodes = IGNITE_SERVER.GetCluster().ForServers().GetNodes();
                    IGNITE_SERVER.GetCluster().SetBaselineTopology(nodes);
                }
                else
                {
                    new Exception("Application Parameters can not be null/Empty!!!");
                }
            }
            catch (Exception ex)
            {
                throw;
            }
        }