コード例 #1
0
ファイル: EditRole.cs プロジェクト: zconduit/LightBlue
        public EditRole(string serviceTitle, MultiHostConfiguration multiHostConfiguration, string multiHostConfigurationFilePath)
        {
            _serviceTitle = serviceTitle;
            _multiHostConfiguration = multiHostConfiguration;
            _multiHostConfigurationFilePath = multiHostConfigurationFilePath;

            RoleConfiguration = _multiHostConfiguration.Roles.Single(x => x.Title == _serviceTitle);
        }
コード例 #2
0
        public void Save(string path, MultiHostConfiguration multiHostConfiguration)
        {
            // This model ensures that we don't persist web related configuration into standard (worker) roles
            var persistanceModel = new
            {
                Roles = from x in multiHostConfiguration.Roles
                        let isWorker = string.IsNullOrWhiteSpace(x.Port)
                        select isWorker
                            ? (dynamic)new
                            {
                                x.EnabledOnStartup,
                                x.Assembly,
                                x.RoleName,
                                x.Title,
                                x.ConfigurationPath,
                                
                                x.RoleIsolationMode,
                            }
                            : (dynamic)new
                            {
                                x.EnabledOnStartup,
                                x.Assembly,
                                x.RoleName,
                                x.Title,
                                x.ConfigurationPath,

                                x.Port,
                                x.UseSsl,
                                x.Hostname,

                                x.RoleIsolationMode,
                            }
            };

            using (var fs = new FileStream(path, FileMode.Truncate, FileAccess.Write))
            using (var sw = new StreamWriter(fs))
            {
                sw.WriteLine(JsonConvert.SerializeObject(persistanceModel, Formatting.Indented));
            }
        }
コード例 #3
0
        public void Save(string path, MultiHostConfiguration multiHostConfiguration)
        {
            // This model ensures that we don't persist web related configuration into standard (worker) roles
            var persistanceModel = new
            {
                Roles = from x in multiHostConfiguration.Roles
                        let isWorker = string.IsNullOrWhiteSpace(x.Port)
                                       select isWorker
                            ? (dynamic) new
                {
                    x.EnabledOnStartup,
                    x.Assembly,
                    x.RoleName,
                    x.Title,
                    x.ConfigurationPath,

                    x.RoleIsolationMode,
                }
                            : (dynamic) new
                {
                    x.EnabledOnStartup,
                    x.Assembly,
                    x.RoleName,
                    x.Title,
                    x.ConfigurationPath,

                    x.Port,
                    x.UseSsl,
                    x.Hostname,

                    x.RoleIsolationMode,
                }
            };

            using (var fs = new FileStream(path, FileMode.Truncate, FileAccess.Write))
                using (var sw = new StreamWriter(fs))
                {
                    sw.WriteLine(JsonConvert.SerializeObject(persistanceModel, Formatting.Indented));
                }
        }
コード例 #4
0
ファイル: App.xaml.cs プロジェクト: johndalin/LightBlue
        protected override void OnStartup(StartupEventArgs e)
        {
            try
            {
                string configFilePath = null;

                if (e.Args.Length != 1)
                {
                    var d = new OpenFileDialog();
                    d.Title = "LightBlue MultiHost: please select multi-host configuration file (.json)";
                    d.Filter = "MultiHost Configuration Files (.json)|*.json";
                    d.CheckFileExists = true;
                    if (d.ShowDialog().GetValueOrDefault())
                    {
                        configFilePath = d.FileName;

                    }
                }
                else
                {
                    configFilePath = e.Args.Single();
                }

                if (string.IsNullOrWhiteSpace(configFilePath))
                {
                    Configuration = new MultiHostConfiguration
                    {
                        Roles = new[]
                        {
                            new RoleConfiguration {Title = "Demo Web Site", RoleName = "WebRole"},
                            new RoleConfiguration
                            {
                                Title = "Demo Web Site 2",
                                RoleName = "WebRole",
                                RoleIsolationMode = "AppDomain"
                            },
                            new RoleConfiguration {Title = "Demo Domain", RoleName = "CommandProcessor"},
                            new RoleConfiguration
                            {
                                Title = "Demo Domain 2",
                                RoleName = "ReadModelPopulator",
                                RoleIsolationMode = "AppDomain"
                            }
                        },
                    };
                }
                else
                {
                    var configDir = Path.GetDirectoryName(configFilePath);
                    var json = File.ReadAllText(configFilePath);
                    Configuration = JsonConvert.DeserializeObject<MultiHostConfiguration>(json);

                    foreach (var c in Configuration.Roles)
                    {
                        c.ConfigurationPath = Path.GetFullPath(Path.Combine(configDir, c.ConfigurationPath));
                        c.Assembly = Path.GetFullPath(Path.Combine(configDir, c.Assembly));
                    }

                    var query =
                        from c in Configuration.Roles
                        let relativePath = c.Assembly.ToLowerInvariant().EndsWith(".dll")
                            ? Path.GetDirectoryName(c.Assembly)
                            : c.Assembly
                        select relativePath;

                    var assemblyLocations = query.ToArray();

                    ThreadRunnerAssemblyCache.Initialise(assemblyLocations);
                    IisExpressHelper.KillIisExpressProcesses();
                    LightBlueConfiguration.SetAsMultiHost();
                }

                base.OnStartup(e);
            }
            catch (Exception ex)
            {
                MessageBox.Show("Could not start multi-host: " + ex.ToTraceMessage());
            }
        }