예제 #1
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="args"></param>
        public static void Run(string[] args)
        {
            try
            {
                McastSrv server = new McastSrv();

                if ((args.Length == 1) && (args[0] == "-start"))
                {
                    using (ServiceController sc = new ServiceController(server.ServiceName))
                    {
                        sc.Start();
                    }
                }
                if ((args.Length == 1) && (args[0] == "-stop"))
                {
                    using (ServiceController sc = new ServiceController(server.ServiceName))
                    {
                        sc.Stop();
                    }
                }
                else if ((args.Length == 1) && (args[0] == "-console"))
                {
                    server.ServiceMain();
                }
                else if (args.Length == 0)
                {
                    ServiceBase.Run(server);
                }
            }
            catch (Exception e)
            {
                _Logger.Fatal("MCAST: " + "ERROR arrancando nodo", e);
            }
        }
예제 #2
0
        /// <summary>
        /// The main entry point for the application.
        /// </summary>
        static void Main(string[] args)
        {
            if ((args.Length == 1) && (args[0] == "-install"))
            {
                if (Environment.OSVersion.Platform != PlatformID.Unix)
                {
                    Native.Kernel32.AttachConsole(Native.Ntdll.GetParentProcessID(Process.GetCurrentProcess().Id));
                }

                McastInstaller installer = new McastInstaller();
                Hashtable      state     = new Hashtable();

                try
                {
                    LogManager.GetCurrentClassLogger().Info("Instalando Servicio");
                    installer.Context = new InstallContext();
                    installer.Context.Parameters["assemblypath"] = Application.ExecutablePath;
                    installer.Install(state);
                }
                catch (Exception ex)
                {
                    installer.Rollback(state);
                    Console.WriteLine("ERROR instalando servicio: {0}", ex.Message);
                    LogManager.GetCurrentClassLogger().Error("ERROR instalando servicio: {0}", ex.Message);
                }
            }
            else if ((args.Length == 1) && (args[0] == "-uninstall"))
            {
                if (Environment.OSVersion.Platform != PlatformID.Unix)
                {
                    Native.Kernel32.AttachConsole(Native.Ntdll.GetParentProcessID(Process.GetCurrentProcess().Id));
                }

                McastInstaller installer = new McastInstaller();

                try
                {
                    LogManager.GetCurrentClassLogger().Info("Desinstalando Servicio");
                    installer.Context = new InstallContext();
                    installer.Uninstall(null);
                }
                catch (Exception ex)
                {
                    Console.WriteLine("ERROR desinstalando servicio: {0}", ex.Message);
                    LogManager.GetCurrentClassLogger().Error("ERROR desinstalando servicio: {0}", ex.Message);
                }
            }
            else
            {
                //LogManager.GetCurrentClassLogger().Info(idioma.translate["Instalando Servicio"]);
                McastSrv.Run(args);
            }
        }