/// <summary> /// 本地服务器-开启当前服务器集群 /// </summary> private void button_LocalServer_StartCluster_Click(object sender, RoutedEventArgs e) { int indexLocalFile = listBox_LocalServer_ClusterFile.SelectedIndex; int indexLocalPath = dataGrid_LocalServer_ServersPath.SelectedIndex; if (indexLocalFile == -1 || indexLocalPath == -1) { return; } //保存当前选中的集群配置 ExtendHelper.CopyAllProperties(UI, m_ClusterInfo_Local[indexLocalFile].ClusterSetting); SavesManager.SetClusterInfo(ComboBox_LocalServer_SavesFolder.SelectedItem?.ToString(), m_ClusterInfo_Local[indexLocalFile]); string confdir = ComboBox_LocalServer_SavesFolder.SelectedItem.ToString(); string cluster = listBox_LocalServer_ClusterFile.SelectedItem.ToString(); string exefile = (dataGrid_LocalServer_ServersPath.SelectedItem as DataRowView)[2].ToString(); bool isShell = (bool)radioButton_LocalServer_OpenType_1.IsChecked; //依次开启集群服务器 foreach (var server in m_ClusterInfo_Local[indexLocalFile].ClusterServers) { string shard = server.Setting.Shard_Master ? "Master" : "Caves"; string parameter = ServersManager.CreatParameter(confdir, cluster, shard); CreatNewProcess(exefile, parameter, isShell, server.Session); } }
private void button_CloudServer_StartCluster_Click(object sender, RoutedEventArgs e) { SftpClient client = ServersManager.GetExistSftp(m_ServerConnect, UI.Location, UI.Username, UI.Password); string nameCloud = ComboBox_CloudServer_SavesFolder.SelectedItem?.ToString(); int indexCloud = listBox_CloudServer_ClusterFile.SelectedIndex; int indexCloudFile = listBox_CloudServer_ClusterFile.SelectedIndex; if (client == null) { return; } ExtendHelper.CopyAllProperties(UI, m_ClusterInfo_Cloud[indexCloud].ClusterSetting); SavesManager.SetClusterInfo(nameCloud, m_ClusterInfo_Cloud[indexCloud], client); string confdir = ComboBox_CloudServer_SavesFolder.SelectedItem.ToString(); string cluster = listBox_CloudServer_ClusterFile.SelectedItem.ToString(); string exefile = (dataGrid_CloudServer_ServersPath.SelectedItem as DataRowView)[2].ToString(); string exepath = exefile.Replace("/dontstarve_dedicated_server_nullrenderer", ""); List <string> screenList = ServersManager.GetExistScreens(UI.Location, UI.Username, UI.Password); foreach (var server in m_ClusterInfo_Cloud[indexCloudFile].ClusterServers) { string shard = server.Setting.Shard_Master ? "Master" : "Caves"; string parameter = ServersManager.CreatParameter(confdir, cluster, shard); string command = string.Empty; string screenName = cluster + "_" + server.Folder; if (screenList.Contains(screenName)) { command = $"screen -xr {screenName}"; } else { command += $"cd {exepath}\r"; command += $"screen -S {screenName} {"./dontstarve_dedicated_server_nullrenderer"} {parameter}"; } CreatNewScreens(UI.Location, UI.Username, UI.Password, command); } }