public void ServerTerminate( ServerLoger loger ) { if (!killing) logers.Remove(loger); }
public void run( bool background, string exePath ) { DirectoryInfo configDir = Prefrences.GetConfigDir(); if (!configDir.Exists) configDir.Create(); DirectoryInfo tempDir = configDir.CreateSubdirectory("temp"); if (tempDir == null || !tempDir.Exists) { MessageBox.Show("Unable to start server, error creating temp dir\n" + tempDir.FullName); return; } if (port < 1) port = 5154; FileInfo configFile = new FileInfo(Path.Combine(tempDir.FullName, port.ToString()+".cfg")); FileStream fs = configFile.Create(); if (fs == null) { MessageBox.Show("Unable to start server, error creating config file\n" + configFile.FullName); return; } buildConfig(fs); fs.Close(); string commandLine = "-conf \"" + configFile.FullName + "\""; if (!background) { ServerLoger loger = new ServerLoger(this); logers.Add(loger); // throw this in a thread, for reals but for now just leave it single threaded for debugin loger.run(exePath, commandLine, Path.Combine(tempDir.FullName, port.ToString() + ".log")); } else { Process proc = new Process(); proc.StartInfo.Arguments = commandLine; proc.StartInfo.FileName = exePath; proc.StartInfo.WorkingDirectory = Path.GetDirectoryName(exePath); proc.Start(); } }