public ResourceMgr_local(ILegacyLogger i_Logger) { int ii; ISMVMC vmc; try { m_Logger = i_Logger; m_iMaxSessions = ConfigParams.GetNumExt(); m_VMCs = new VMCList(); Monitor.Enter(m_Lock); for (ii = 0; ii < m_iMaxSessions; ii++) { vmc = new ISMVMC(); vmc.Clear(); m_VMCs.Add(new VMCInfo(ref vmc)); } } catch (Exception exc) { m_Logger.Log(Level.Exception, "RMl ctor caught exception: " + exc.ToString()); } finally { Monitor.Exit(m_Lock); } } // ctor
} // MsgLoop public bool StartSBComponents() { bool bRet = true, bRes = true; string sStarts = ""; StringCollection asBins = null, asMonoBins = null; StringBuilder sbLauncherApps = null; int ii, iMaxSessions = 0; string sMonoBinPath = "", sBinPath = "", sCfgPath = "", sLogPath = ""; string sCmd = ""; StringBuilder sbArgs = null; char cSlash; string[] asLauncherSupportedApps = { m_csAppNameAudiortr }; // FIX: This should instead by initialized by calling `SBLauncher --supported` and reading in the results from stdin. bool bLauncherStartedAudiortr = false; try { if (RunningSystem.RunningPlatform == CLRPlatform.Mono) { cSlash = '/'; } else { //cSlash = '\\'; // We can use '/' on Windows too. cSlash = '/'; } sMonoBinPath = ConfigurationManager.AppSettings["MonoBinPath"]; if (!(sMonoBinPath.EndsWith("/")) && !(sMonoBinPath.EndsWith("\\"))) { sMonoBinPath += cSlash; } sBinPath = ConfigurationManager.AppSettings["DefaultBinPath"]; if (!(sBinPath.EndsWith("/")) && !(sBinPath.EndsWith("\\"))) { sBinPath += cSlash; } if (m_bDesktopRuntime == true) { sMonoBinPath += "mono " + SBLocalRM.g_sDesktopArg + " " + sBinPath; } else { sMonoBinPath += "mono " + sBinPath; } sLogPath = ConfigurationManager.AppSettings["DefaultLogFilePath"]; if (!(sLogPath.EndsWith("/")) && !(sLogPath.EndsWith("\\"))) { sLogPath += cSlash; } sCfgPath = ConfigurationManager.AppSettings["DefaultConfigPath"]; if (!(sCfgPath.EndsWith("/")) && !(sCfgPath.EndsWith("\\"))) { sCfgPath += cSlash; } iMaxSessions = ConfigParams.GetNumExt(); // Binary executables to start asBins = new StringCollection(); sStarts = ConfigurationManager.AppSettings["BinsToStart"]; bRes = Utilities.GetItemsFromString(sStarts, ';', asBins); // Mono binaries to start asMonoBins = new StringCollection(); sStarts = ConfigurationManager.AppSettings["MonoBinsToStart"]; bRes = Utilities.GetItemsFromString(sStarts, ';', asMonoBins); sbArgs = new StringBuilder(); // Launch Mono executables try { if (asMonoBins.Contains(m_csAppNameAudiomgr)) { sbArgs.Length = 0; // sCmd = sMonoBinPath + "AudioMgr.exe"; sCmd = sBinPath + "AudioMgr.sh"; // Launch script to get around bug introduced in Mono 2.6.3 where Mono EXEs fail to launch directly. FIX - Change this back once they fix it, we don't want the extra 'sh' overhead. /* Redirection like this doesn't work on mono/linux * sCmd += " >/dev/null"; // FIX - won't work on Mono for Windows * * if(sLogPath.Length > 0) * { * sbArgs.AppendFormat(" 2>>{0}AudioMgr.stderr.log", sLogPath); * } * else * { * sbArgs.AppendFormat("2>>/home/speechbridge/logs/AudioMgr.stderr.log"); // FIX - Won't work on Mono for Windows * } */ m_Logger.Log(Level.Debug, "LRMWorkerThread.StartSBComponents: Starting '" + sCmd + sbArgs.ToString() + "'."); bRes = StartSBProc(m_csAppNameAudiomgr, sCmd, sbArgs.ToString()); } } catch (Exception exc) { m_Logger.Log(exc); } try { if (asMonoBins.Contains(m_csAppNameDialogmgr)) { sbArgs.Length = 0; // sCmd = sMonoBinPath + "DialogMgr.exe"; sCmd = sBinPath + "DialogMgr.sh"; // Launch script to get around bug introduced in Mono 2.6.3 where Mono EXEs fail to launch directly. FIX - Change this back once they fix it, we don't want the extra 'sh' overhead. /* * sCmd += " >/dev/null"; // FIX - won't work on Mono for Windows * * if(sLogPath.Length > 0) * { * sbArgs.AppendFormat("2>>{0}DialogMgr.stderr.log", sLogPath); * } * else * { * sbArgs.AppendFormat("2>>/home/speechbridge/logs/DialogMgr.stderr.log"); * } */ m_Logger.Log(Level.Debug, "LRMWorkerThread.StartSBComponents: Starting '" + sCmd + " " + sbArgs.ToString() + "'."); bRes = StartSBProc(m_csAppNameDialogmgr, sCmd, sbArgs.ToString()); } } catch (Exception exc) { m_Logger.Log(exc); } try { if (asMonoBins.Contains(m_csAppNameSbsched)) { sbArgs.Length = 0; // sCmd = sMonoBinPath + "SBSched.exe"; sCmd = sBinPath + "SBSched.sh"; // Launch script to get around bug introduced in Mono 2.6.3 where Mono EXEs fail to launch directly. FIX - Change this back once they fix it, we don't want the extra 'sh' overhead. m_Logger.Log(Level.Debug, "LRMWorkerThread.StartSBComponents: Starting '" + sCmd + " " + sbArgs.ToString() + "'."); bRes = StartSBProc(m_csAppNameSbsched, sCmd, sbArgs.ToString()); } } catch (Exception exc) { m_Logger.Log(exc); } // Launch executables // FIX - Check that Mono bins aren't here? (I.e., config file error) try { if (asBins.Contains(m_csAppNameAudiomgr)) { sbArgs.Length = 0; sCmd = sBinPath + "AudioMgr.exe"; /* Redirection like this doesn't work on mono/linux * if(sLogPath.Length > 0) * { * sbArgs.AppendFormat("2>>{0}AudioMgr.stderr.log", sLogPath); * } */ m_Logger.Log(Level.Debug, "LRMWorkerThread.StartSBComponents: Starting '" + sCmd + " " + sbArgs.ToString() + "'."); bRes = StartSBProc(m_csAppNameAudiomgr, sCmd, sbArgs.ToString()); } } catch (Exception exc) { m_Logger.Log(exc); } try { if (asBins.Contains(m_csAppNameDialogmgr)) { sbArgs.Length = 0; sCmd = sBinPath + "DialogMgr.exe"; /* Redirection like this doesn't work on mono/linux * if(sLogPath.Length > 0) * { * sbArgs.AppendFormat("2>>{0}DialogMgr.stderr.log", sLogPath); * } */ m_Logger.Log(Level.Debug, "LRMWorkerThread.StartSBComponents: Starting '" + sCmd + " " + sbArgs.ToString() + "'."); bRes = StartSBProc(m_csAppNameDialogmgr, sCmd, sbArgs.ToString()); } } catch (Exception exc) { m_Logger.Log(exc); } try { if (asBins.Contains(m_csAppNameSbsched)) { sbArgs.Length = 0; sCmd = sBinPath + "SBSched.exe"; m_Logger.Log(Level.Debug, "LRMWorkerThread.StartSBComponents: Starting '" + sCmd + " " + sbArgs.ToString() + "'."); bRes = StartSBProc(m_csAppNameSbsched, sCmd, sbArgs.ToString()); } } catch (Exception exc) { m_Logger.Log(exc); } // Launch SIP Proxy server try { if (asBins.Contains(m_csAppNameProxysrv)) { sbArgs.Length = 0; sCmd = sBinPath + m_csAppNameProxysrv; sbArgs.AppendFormat("-x -i {0}ProxySrv.config -l {1}ProxySrv.log", sCfgPath, sLogPath); m_Logger.Log(Level.Debug, "LRMWorkerThread.StartSBComponents: Starting '" + sCmd + " " + sbArgs.ToString() + "'."); bRes = StartSBProc(m_csAppNameProxysrv, sCmd, sbArgs.ToString()); } } catch (Exception exc) { m_Logger.Log(exc); } // Start SBLauncher. For now, this should be second to last, since it is only starting AudioRtr. // FIX: If it takes on more launching duties, it should be moved accordingly. try { if (asBins.Contains(m_csAppNameSblauncher)) { sbLauncherApps = new StringBuilder(); for (ii = 0; ii < asLauncherSupportedApps.Length; ii++) { if (asBins.Contains(asLauncherSupportedApps[ii])) { sbLauncherApps.Append(asLauncherSupportedApps[ii]); sbLauncherApps.Append(' '); if (asLauncherSupportedApps[ii] == m_csAppNameAudiortr) { bLauncherStartedAudiortr = true; } } else { m_Logger.Log(Level.Warning, "LWT.StartSBComponents: Unsupported app '" + asLauncherSupportedApps[ii] + "'."); } } sbArgs.Length = 0; sCmd = sBinPath + m_csAppNameSblauncher; sbArgs.AppendFormat("{0} {1} {2} {3} {4}", iMaxSessions, sBinPath, sCfgPath, sLogPath, sbLauncherApps.ToString()); m_Logger.Log(Level.Debug, "LRMWorkerThread.StartSBComponents: Starting '" + sCmd + " " + sbArgs.ToString() + "'."); bRes = StartSBProc(m_csAppNameSblauncher, sCmd, sbArgs.ToString()); } } catch (Exception exc) { m_Logger.Log(exc); } // Launch AudioRtrs last try { if (!bLauncherStartedAudiortr && asBins.Contains(m_csAppNameAudiortr)) { for (ii = 0; ii < iMaxSessions; ii++) { sbArgs.Length = 0; //sCmd = sBinPath + "gua"; sCmd = sBinPath + m_csAppNameAudiortr; //sbArgs.AppendFormat("-f {0}{1}.cfg >>{2}AudioRtr_p{3}.log 2>>{4}AudioRtr_p{5}.stderr.log", sCfgPath, ii, sLogPath, ii, sLogPath, ii); sbArgs.AppendFormat("-f {0}{1}.cfg", sCfgPath, ii); m_Logger.Log(Level.Debug, "LRMWorkerThread.StartSBComponents: Starting '" + sCmd + " " + sbArgs.ToString() + "'."); bRes = StartSBProc(m_csAppNameAudiortr, sCmd, sbArgs.ToString()); } } } catch (Exception exc) { m_Logger.Log(exc); } } catch (Exception exc) { bRet = false; m_Logger.Log(exc); } return(bRet); } // StartSBComponents