Ejemplo n.º 1
0
        /// <summary>
        /// Handles the performance counter installation if they don't
        /// already exist.
        /// </summary>
        /// <returns>The application's <see cref="PerfCounterSet" />.</returns>
        public static PerfCounterSet InstallPerfCounters()
        {
            bool           exists = PerformanceCounterCategory.Exists(SwitchConst.NeonSwitchPerf);
            PerfCounterSet perfCounters;

            perfCounters = new PerfCounterSet(false, true, SwitchConst.NeonSwitchPerf, SwitchConst.NeonSwitchName);

            if (!exists)
            {
                CorePerf.Install(perfCounters);

                perfCounters.Install();
            }

            return(perfCounters);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// The main application entry point.
        /// </summary>
        protected override void Main()
        {
            // Initialize the environment.

            SysLog.LogProvider = new SwitchLogProvider();

            var assembly = Assembly.GetExecutingAssembly();

            Helper.InitializeApp(assembly);
            Config.SetConfigPath(assembly);
            CorePerf.Initialize();

            CoreApp.InstallPath = Helper.GetAssemblyFolder(Helper.GetEntryAssembly());

            // Initialize the global NeonSwitch related variables.

            Switch.SetGlobal(SwitchGlobal.NeonSwitchVersion, Build.Version);
            Switch.SetGlobal(SwitchGlobal.FreeSwitchVersion, Helper.GetVersionString(Assembly.GetAssembly(typeof(freeswitch))));

            // Load the application configuration settings.

            CoreApp.Config         = new Config("NeonSwitch");
            CoreApp.BkTaskInterval = CoreApp.Config.Get("BkTaskInterval", TimeSpan.FromSeconds(1));

            // Load the switch subcommand handlers.

            Switch.RegisterAssemblySubcommands(assembly);

            // Create a service host for the application service and launch it.

            var logProvider =
                new CompositeSysLogProvider(
                    new NativeSysLogProvider(SwitchConst.NeonSwitchName),
                    new SwitchLogProvider());

            serviceHost = new SwitchServiceHost();
            serviceHost.Initialize(new string[0], new CoreAppService(), logProvider, true);
        }