public int Run()
        {
            if (siloHost == null)
            {
                return(1);
            }

            try
            {
                siloHost.InitializeOrleansSilo();

                if (siloHost.StartOrleansSilo())
                {
                    Console.WriteLine($"Successfully started Orleans silo '{siloHost.Name}' as a {siloHost.Type} node.");
                    return(0);
                }
                else
                {
                    throw new OrleansException($"Failed to start Orleans silo '{siloHost.Name}' as a {siloHost.Type} node.");
                }
            }
            catch (Exception exc)
            {
                siloHost.ReportStartupError(exc);
                Console.Error.WriteLine(exc);
                return(1);
            }
        }
        public bool Run()
        {
            bool ok = false;

            try
            {
                siloHost.InitializeOrleansSilo();

                ok = siloHost.StartOrleansSilo();

                if (ok)
                {
                    Console.WriteLine(string.Format("Successfully started Orleans silo '{0}' as a {1} node.", siloHost.Name, siloHost.Type));
                }
                else
                {
                    throw new SystemException(string.Format("Failed to start Orleans silo '{0}' as a {1} node.", siloHost.Name, siloHost.Type));
                }
            }
            catch (Exception exc)
            {
                siloHost.ReportStartupError(exc);
                var msg = string.Format("{0}:\n{1}\n{2}", exc.GetType().FullName, exc.Message, exc.StackTrace);
                Console.WriteLine(msg);
            }

            return(ok);
        }
        public bool Run()
        {
            bool ok = false;

            try
            {
                siloHost.InitializeOrleansSilo();

                siloHost.Config.Globals.RegisterBootstrapProvider <Dashboard>("Dashboard");

                ok = siloHost.StartOrleansSilo();
                if (!ok)
                {
                    throw new SystemException(string.Format("Failed to start Orleans silo '{0}' as a {1} node.", siloHost.Name, siloHost.Type));
                }
            }
            catch (Exception exc)
            {
                siloHost.ReportStartupError(exc);
                var msg = string.Format("{0}:\n{1}\n{2}", exc.GetType().FullName, exc.Message, exc.StackTrace);
                Console.WriteLine(msg);
            }

            return(ok);
        }
        public bool Run()
        {
            bool ok = false;

            try
            {
                _siloHost.InitializeOrleansSilo();

                ok = _siloHost.StartOrleansSilo();

                if (ok)
                {
                    Console.WriteLine($"Successfully started Orleans silo '{_siloHost.Name}' as a {_siloHost.Type} node.");
                }
                else
                {
                    throw new SystemException(
                              $"Failed to start Orleans silo '{_siloHost.Name}' as a {_siloHost.Type} node.");
                }
            }
            catch (Exception exc)
            {
                _siloHost.ReportStartupError(exc);
                var msg = $"{exc.GetType().FullName}:\n{exc.Message}\n{exc.StackTrace}";
                Console.WriteLine(msg);
            }

            return(ok);
        }
        public bool Run()
        {
            var ok = false;

            try
            {
                siloHost.InitializeOrleansSilo();
                ok = siloHost.StartOrleansSilo();

                if (ok)
                {
                    System.Console.WriteLine("OrleansHostWrapper", "Run", "Successfully started Orleans silo '{0}' as a {1} node.", siloHost.Name, siloHost.Type);
                }
                else
                {
                    var message = string.Format("Failed to start Orleans silo '{0}' as a {1} node.", siloHost.Name, siloHost.Type);
                    throw new SystemException(message);
                }
            }
            catch (Exception ex)
            {
                siloHost.ReportStartupError(ex);
                System.Console.WriteLine("OrleansHostWrapper", "Run", "{0}:\n{1}\n{2}", ex.GetType().FullName, ex.Message, ex.StackTrace);
            }

            return(ok);
        }
Exemple #6
0
        /// <summary>
        /// Initialise and starts SiloHost reporting any issues
        /// </summary>
        /// <returns></returns>
        public int Start()
        {
            if (_siloHost != null)
            {
                throw new Exception("Silo server is already running");
            }

            if (_clusterConfiguration == null)
            {
                throw new Exception("ClusterConfiguration has not been setup yet");
            }

            _siloHost = new SiloHost($"MemoryChatSilo-{Guid.NewGuid()}", _clusterConfiguration);

            try
            {
                _siloHost.InitializeOrleansSilo();

                if (_siloHost.StartOrleansSilo())
                {
                    Console.WriteLine($"Successfully started silo server {_siloHost.Name}");
                    return(0);
                }
                else
                {
                    throw new OrleansException($"Failed to start silo server {_siloHost.Name}");
                }
            }
            catch (Exception ex)
            {
                _siloHost.ReportStartupError(ex);
                Console.Error.WriteLine(ex);
                return(1);
            }
        }
Exemple #7
0
        public bool Run()
        {
            bool ok = false;

            try
            {
                siloHost.InitializeOrleansSilo();

                //siloHost.Config.Defaults.DefaultTraceLevel = Runtime.Severity.Verbose3;

                siloHost.Config.Globals
                .RegisterBootstrapProvider <OrleansDashboard.Dashboard>("OrleansDashboard");

                siloHost.Config.AddSimpleMessageStreamProvider("SimpleStreamProvider");

                siloHost.Config.AddMemoryStorageProvider("PubSubStore");



                siloHost.Config.Globals
                .RegisterBootstrapProvider <MetricsTrackerBootstrapProvider>("MetricsTracker");

                ok = siloHost.StartOrleansSilo();

                if (ok)
                {
                    Console.WriteLine(string.Format("Successfully started Orleans silo '{0}' as a {1} node.", siloHost.Name, siloHost.Type));
                }
                else
                {
                    throw new SystemException(string.Format("Failed to start Orleans silo '{0}' as a {1} node.", siloHost.Name, siloHost.Type));
                }
            }
            catch (Exception exc)
            {
                siloHost.ReportStartupError(exc);
                var msg = string.Format("{0}:\n{1}\n{2}", exc.GetType().FullName, exc.Message, exc.StackTrace);
                Console.WriteLine(msg);
            }

            return(ok);
        }
        public bool Stop()
        {
            try
            {
                _silo.ShutdownOrleansSilo();
                _silo.WaitForOrleansSiloShutdown();
            }
            catch (Exception exception)
            {
                _silo.ReportStartupError(exception);
                Console.WriteLine(exception);

                return(false);
            }
            return(true);
        }
Exemple #9
0
        public bool Stop()
        {
            Console.WriteLine("Stopping SiloHost...");

            try
            {
                _siloHost.StopOrleansSilo();
                _siloHost.Dispose();
                GC.SuppressFinalize(_siloHost);
                Console.WriteLine($"Orleans silo '{_siloHost.Name}' shutdown.");
                return(true);
            }
            catch (Exception exc)
            {
                _siloHost.ReportStartupError(exc);
                var msg = $"{exc.GetType().FullName}:\n{exc.Message}\n{exc.StackTrace}";
                Console.WriteLine(msg);
                return(false);
            }
        }
Exemple #10
0
        public bool Start()
        {
            Console.WriteLine("Starting SiloHost...");

            var config = new ClusterConfiguration();

            config.LoadFromFile(_configPath);

            _siloHost = new SiloHost(_siloName, config);

            try
            {
                // if we run not DEV env, we need special initialization for Consul
                if (_siloHost.Config.Globals.LivenessType != GlobalConfiguration.LivenessProviderType.MembershipTableGrain)
                {
                    _siloHost.Config.Globals.LivenessType            = GlobalConfiguration.LivenessProviderType.Custom;
                    _siloHost.Config.Globals.MembershipTableAssembly = "OrleansConsulUtils";
                    _siloHost.Config.Globals.ReminderServiceType     = GlobalConfiguration.ReminderServiceProviderType.Disabled;
                }
                _siloHost.InitializeOrleansSilo();
                var ok = _siloHost.StartOrleansSilo();

                Console.WriteLine(ok
                    ? $"Successfully started Orleans silo '{_siloHost.Name}' as a {_siloHost.Type} node."
                    : $"Failed to start Orleans silo '{_siloHost.Name}' as a {_siloHost.Type} node.");

                return(ok);
            }
            catch (Exception exc)
            {
                _siloHost.ReportStartupError(exc);
                var msg = $"{exc.GetType().FullName}:\n{exc.Message}\n{exc.StackTrace}";
                Console.WriteLine(msg);
                return(false);
            }
        }
Exemple #11
0
        static int Main(string[] args)
        {
            string environment = Environment.GetEnvironmentVariable("ASPNETCORE_ENVIRONMENT") ?? "Development";
            var    builder     = new ConfigurationBuilder()
                                 .SetBasePath(Directory.GetCurrentDirectory())
                                 .AddInMemoryCollection(new Dictionary <string, string> // add default settings, that will be overridden by commandline
            {
                { "Id", "OrleansHost" },
                { "Version", "1.0.0" },
                { "DeploymentId", "testdeploymentid" },
            })
                                 .AddCommandLine(args)
                                 .AddJsonFile($"appconfig.json", optional: true)
                                 .AddJsonFile($"appconfig.{environment}.json", optional: true)
                                 .AddEnvironmentVariables("ASPNETCORE_"); // The CloudService will pass settings (such as) the connectionstring through environment variables

            if ("Development".Equals(environment) && builder.GetFileProvider().GetFileInfo("OrleansHost.csproj").Exists)
            {
                // For more details on using the user secret store see http://go.microsoft.com/fwlink/?LinkID=532709
                builder.AddUserSecrets <Program>();
            }

            var config = builder.Build();

            loggerFactory.AddConsole(config.GetSection("Logging"));
            loggerFactory.AddDebug();
            var logger = loggerFactory.CreateLogger <Program>();

            ClusterConfiguration clusterConfig = ClusterConfiguration.LocalhostPrimarySilo();

            clusterConfig.Globals.DeploymentId         = config["Id"];
            clusterConfig.Globals.DataConnectionString = config.GetConnectionString("DataConnectionString");
            clusterConfig.AddMemoryStorageProvider("Default");
            clusterConfig.AddMemoryStorageProvider("PubSubStore");
            clusterConfig.AddSimpleMessageStreamProvider("Default");
            clusterConfig.Defaults.DefaultTraceLevel = Orleans.Runtime.Severity.Warning;
            clusterConfig.Defaults.TraceFileName     = "";
            clusterConfig.UseStartupType <Startup>();

            var siloHost = new SiloHost(config["Id"], clusterConfig);

            try
            {
                siloHost.InitializeOrleansSilo();
                bool ok = siloHost.StartOrleansSilo(catchExceptions: false);

                if (!ok)
                {
                    logger.LogError(string.Format($"Failed to start Orleans silo '{siloHost.Name}' as a {siloHost.Type} node."));
                    return(1);
                }
            }
            catch (Exception exc)
            {
                siloHost.ReportStartupError(exc);
                return(2);
            }

            Console.WriteLine("OrleansHost is running. Press [Ctrl]-C to stop...");
            siloHost.WaitForOrleansSiloShutdown();
            // logger.LogInformation(string.Format($"Orleans silo '{siloHost.Name}' shutdown. Press [Enter]"));
            // Console.ReadLine();
            return(0);
        }